我正在尝试用apache2运行我的django项目,因为我需要测试子域名。 我已成功安装 apache2 和 mod_wsgi ,我正在使用 ubuntu 13.4
之后我在我的网站上创建了一个名为 secondweb.conf 的conf
/etc/apache2/sites-available/
具有以下代码
<VirtualHost *:80>
WSGIScriptAlias / /home/nihan/secondweb.wsgi
ServerName secondweb.com
<Directory /home/nihan/website/ >
Order allow,deny
Allow from all
</Directory>
</VirtualHost>
在我的/home/nihan/secondweb.wsgi
我有这段代码
import os
import sys
os.environ['DJANGO_SETTINGS_MODULE'] = 'website.settings'
path = '/home/nihan/website'
if path not in sys.path:
sys.path.append(path)
import django.core.handlers.wsgi
application = django.core.handlers.wsgi.WSGIHandler()
我已使用此代码检查了我的secondweb.wsgi
def application(environ, start_response):
status = '200 OK'
output = 'Hello World!'
response_headers = [('Content-type', 'text/plain'),
('Content-Length', str(len(output)))]
start_response(status, response_headers)
return [output]
没关系。
但当我试图用我的django项目挂钩时,home/nihan/website
使用此代码
import os
import sys
os.environ['DJANGO_SETTINGS_MODULE'] = 'website.settings'
path = '/home/nihan/website'
if path not in sys.path:
sys.path.append(path)
import django.core.handlers.wsgi
application = django.core.handlers.wsgi.WSGIHandler()
它给了我 http 500错误 为了摇晃测试,我在我的主目录中创建了另一个名为 mysite 的项目 当我用这段代码挂上 secondweb.wsgi 时
import os
import sys
os.environ['DJANGO_SETTINGS_MODULE'] = 'mysite.settings'
path = '/home/nihan/mysite'
if path not in sys.path:
sys.path.append(path)
import django.core.handlers.wsgi
application = django.core.handlers.wsgi.WSGIHandler()
该网站运行良好。
只是想知道这个问题是什么?我的网站文件夹的心情是777 请帮帮我