Django/mod_wsgi WAMP with PHP

匿名 (未验证) 提交于 2019-12-03 01:43:02

问题:

I followed this guide and managed to make Python with a Django installation work perfectly, but it seems to have rendered all the locally hosted PHP sites inaccessible returning a 404 error.

httpd.conf

LoadModule wsgi_module modules/mod_wsgi.so  #This is placed right after the rule for <Directory "f:/WAMP/www/"> <Directory "f:/WAMP/www/python">     Options ExecCGI     AddHandler wsgi-script .py     Order allow,deny     Allow from all </Directory>  #This is placed at the end of the file <IfModule ssl_module> SSLRandomSeed startup builtin SSLRandomSeed connect builtin </IfModule>  Include "f:/WAMP/alias/*" Include "F:/WAMP/www/python/sandbox/apache/apache_django_wsgi.conf" 

apache_django_wsgi.conf

Alias /python/images/ "F:/WAMP/www/python/sandbox/images" <Directory "F:/WAMP/www/python/sandbox/images"> Order allow,deny Allow from all </Directory>  WSGIScriptAlias /python "F:/WAMP/www/python/sandbox/apache/django.wsgi"  <Directory "F:/WAMP/www/python/sandbox/apache"> Allow from all </Directory>  <VirtualHost *:80> DocumentRoot f:/WAMP/www/python/sandbox/ ServerName 127.0.0.1 </VirtualHost> 

django.wsgi

import os, sys  sys.path.append('F:/WAMP/www/python/sandbox') os.environ['DJANGO_SETTINGS_MODULE'] = 'sandbox.settings'  import django.core.handlers.wsgi application = django.core.handlers.wsgi.WSGIHandler() 

PHP only renders when I comment out the lastline from httpd.conf.

回答1:

You need to have another virtual host if you're going to set the DocumentRoot:

# This is for PHP <VirtualHost *:80> DocumentRoot f:/WAMP/www/ ServerName local.php.dev </VirtualHost>  # This is for your Django stuff <VirtualHost *:80> DocumentRoot f:/WAMP/www/python/sandbox/ ServerName local.py.dev </VirtualHost> 

Otherwise, as it is now, all the local requests are being sent to the python sandbox.

Note that you'll need to have several hosts pointing locally.



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