0
我遵循this guide,並設法使Python與Django的安裝工作完美無瑕,但它似乎讓所有本地託管的PHP站點都無法訪問,從而返回404錯誤。Django/mod_wsgi使用PHP的WAMP
的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上當我從httpd.conf註釋掉最後一行時,它會呈現。
這行'DocumentRoot f:/ WAMP/www/python/sandbox /'將把所有內容發送到該目錄。我想你需要另一個虛擬主機來運行PHP。 –
我懷疑是否有辦法將該特定規則本地化爲python/django目錄?設置多個虛擬主機的效率似乎低得多。 –
效率不高,這是所有Apache網站的工作方式。您需要編輯您的主機文件並創建2個名爲python.dev和php.dev的站點。然後分別爲python vhost和php vhost創建'ServerName'。 –