开发者

how to combine django and wordpress based on ubuntu and nginx

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 h开发者_Go百科ow to combine the django and wordpress together.any tips is wonderful. thanks in advance!


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.


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.


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:

  • Try to adopt django admin to your needs;
  • Use Django CMS (it's a super-great thing!);
  • Use one of the Django blogs.


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

WordPress and Django: best buddies

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜