Django / mod_wsgi带PHP的WAMP [英] Django/mod_wsgi WAMP with PHP
问题描述
我遵循本指南,并设法使Python与Django安装工作完美,但似乎已经使所有本地托管的PHP站点无法访问返回404错误。
httpd.conf
LoadModule wsgi_module modules / mod_wsgi.so
#这是放在< Directory的规则之后f:/ WAMP / www />
<目录f:/ WAMP / www / python>
选项ExecCGI
AddHandler wsgi-script .py
订单允许,拒绝
允许从所有
< / Directory>
#这被放在文件的末尾
< IfModule ssl_module>
SSLRandomSeed启动内置
SSLRandomSeed连接内置
< / IfModule>
包含f:/ WAMP /别名/ *
包含F:/WAMP/www/python/sandbox/apache/apache_django_wsgi.conf
apache_django_wsgi.conf
code>别名/ python / images /F:/ WAMP / www / python / sandbox / images
< DirectoryF:/ WAMP / www / python / sandbox / images>
订单允许,拒绝
允许从所有
< / Directory>
WSGIScriptAlias / pythonF:/WAMP/www/python/sandbox/apache/django.wsgi
< DirectoryF:/ WAMP / www / python /沙箱/阿帕奇>
允许从所有
< / Directory>
< VirtualHost *:80>
DocumentRoot f:/ WAMP / www / python / sandbox /
ServerName 127.0.0.1
< / VirtualHost>
django.wsgi
pre>
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()
只有当我注释掉httpd.conf中的最后一行时,PHP才会呈现。
如果要设置 DocumentRoot
,则需要另一个虚拟主机:
#这是PHP
< VirtualHost *:80>
DocumentRoot f:/ WAMP / www /
ServerName local.php.dev
< / VirtualHost>
#这是为您的Django的东西
< VirtualHost *:80>
DocumentRoot f:/ WAMP / www / python / sandbox /
ServerName local.py.dev
< / VirtualHost>
否则,现在,所有的本地请求都被发送到python沙箱。 p>
请注意,您需要在本地指定几台主机。
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.
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.
这篇关于Django / mod_wsgi带PHP的WAMP的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!