Django (wsgi) and Wordpress coexisting in Apache virtualhost

最后都变了- 提交于 2019-11-27 13:50:10
Graham Dumpleton

Replace:

DocumentRoot /var/empty

with:

DocumentRoot /home/zach/projects/python/myproject/wordpress

Remove:

Alias / /home/zach/projects/python/myproject/wordpress/

Replace:

WSGIScriptAlias /accounts /home/zach/projects/python/myproject/app/privio.wsgi
WSGIScriptAlias /studio /home/zach/projects/python/myproject/app/privio.wsgi

with:

WSGIScriptAliasMatch ^(/(accounts|studio)) /home/zach/projects/python/myproject/app/privio.wsgi$1

In other words, use DocumentRoot to refer to wordpress that needs to be at root of site and not Alias directive.

The WSGIScriptAliasMatch is so Django itself thinks it is still mounted at root site even though only nominated sub URLs of it are actually passed through. This simplifies things for urls.py.

Note that the $1 at end of WSGI script path is important, so don't leave it off.

Manoj Govindan

Paging Graham Dumpleton :)

I'd venture a guess that the line

Alias / /home/zach/projects/python/myproject/wordpress/

overrides everything below it. Therefore any requests to /accounts will be processed by the wordpress application rather than by the Django application.

From the documentation:

Mounting At Root Of Site

If instead you want to mount a WSGI application at the root of a site, simply list '/' as the mount point when configuring the WSGIScriptAlias directive.

WSGIScriptAlias / /usr/local/www/wsgi-scripts/myapp.wsgi

Do note however that doing so will mean that any static files contained in the DocumentRoot will be hidden and requests against URLs pertaining to the static files will instead be processed by the WSGI application.

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!