如何基于ubuntu和nginx结合django和wordpress

发布于 2024-11-05 08:41:04 字数 139 浏览 0 评论 0原文

现在我有一个基于django(python框架)的网站,可以稳定运行。 在这个网站中我们需要使用wordpress作为cms。 ubuntu 和 nginx 上的服务器配置, 但我不知道如何结合django和wordpress 在一起。任何提示都很棒。 提前致谢!

now I have a site which based on django(the python framework) which can run stable.
in this site we need to use wordpress as a cms.
the server config on ubuntu and nginx,
but i don't know how to combine the django and wordpress
together.any tips is wonderful.
thanks in advance!

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(4

婴鹅 2024-11-12 08:41:05

我认为,从理论上讲,这是可能的,但实际上,你会遇到很多麻烦,以至于不值得。 python中的Django,PHP中的Wordpress,它们都有自己的数据库结构,呃……

我不知道,为什么你需要wordpress(也许你有一个经理或客户“只是想要一个wordpress!” ),但请考虑这些变体:

I think that, in theory, this is possible, but really, you will have so much trouble with it, that it's just not worth it. Django in on python, Wordpress in in PHP, both of them have their own database structure, urghhh...

I don't know, why you need the wordpress (maybe you have a manager or client that "just wants a wordpress!"), but consider those variants:

栀子花开つ 2024-11-12 08:41:05

下面是采用 django 管理界面来管理 wordpress 的具体示例:

WordPress 和 Django:最好的伙伴

Here is the specific example of adopting django admin interface to take care of wordpress:

WordPress and Django: best buddies

帝王念 2024-11-12 08:41:04

如果您尝试集成以前存在的 Wordpress 数据库,您可以使用 Django 的 ./manage.pyspectdb 为您自动生成模型。 Wordpress 有一个极其简单的数据库,它可能会做得相当不错。或者,您可以使用 mezzanine ,它可以导入 WordPress 数据,并且是一个建立在 Django 之上的相当不错的博客。最后,您可以编辑 nginx.conf 并让 nginx 从一个路径/域提供 WordPress,从另一个路径/域提供 django。

示例 nginx.conf(在 blog.example.com 上使用 wordpress,在 example.com 上使用 django):

# wordpress
server {
    listen 80;
    server_name blog.domain.com;

    root /path/to/wordpress;
    index index.html index.php;

    location ~ .php$ {
        expires    off;
        include fastcgi_params;
        fastcgi_pass    127.0.0.1:9000;
        fastcgi_index   index.php;
        fastcgi_param   SCRIPT_FILENAME  /path/to/wordpress/$fastcgi_script_name;
    }
}

# django
server {
    listen 80;
    server_name domain.com;

    location / {
        uwsgi_pass  127.0.0.1:3031;
        include uwsgi_params;
    }
}

或者,您可以将 wordpress 粘贴到子文件夹中,例如 /blog。

If you are trying to integrate a previously existing Wordpress database you can use Django's ./manage.py inspectdb to autogenerate models for you. Wordpress has an extremely simplistic database, it would probably do a fairly decent job. Alternately you could use mezzanine which can import wordpress data, and is a fairly nice blog built on top of Django. Finally you can just edit your nginx.conf and have nginx serve wordpress from one path/domain and django from another.

Example nginx.conf (with wordpress on blog.example.com and django on example.com):

# wordpress
server {
    listen 80;
    server_name blog.domain.com;

    root /path/to/wordpress;
    index index.html index.php;

    location ~ .php$ {
        expires    off;
        include fastcgi_params;
        fastcgi_pass    127.0.0.1:9000;
        fastcgi_index   index.php;
        fastcgi_param   SCRIPT_FILENAME  /path/to/wordpress/$fastcgi_script_name;
    }
}

# django
server {
    listen 80;
    server_name domain.com;

    location / {
        uwsgi_pass  127.0.0.1:3031;
        include uwsgi_params;
    }
}

Alternately you could stick wordpress into a subfolder, like /blog.

御守 2024-11-12 08:41:04

如果您可以将 Django 和 Wordpress 作为单独的应用程序运行,则可以使用 nginx 来处理发送到哪个应用程序的请求。

例如,如果您想要 WordPress 的 CMS 部分只是一个博客,您可以让 nginx 将 example.com/blog/ 发送到 wordpress,并将其他任何内容发送到 django。

If you can get away with running Django and Wordpress as separate apps, you can just use nginx to handle which requests go to which app.

For example, if the CMS portion you'd like Wordpress for is only a blog, you could have nginx send example.com/blog/ to wordpress, and anything else to django.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文