我正在尝试运行django(1.4或更高版本)项目,以便可以通过互联网访问它。我安装了apache和mod-wsgi。仅在浏览器中输入IP就会产生“It works”输出。在/ etc / apache2 / sites-available / location我创建了一个带有
的文件example.com<VirtualHost *:80>
ServerName example.com
ServerAlias example.com
WSGIScriptAlias / /home/user/workspace/project/project/wsgi.py
<Directory /home/user/workspace/project/project/>
Options None
Order deny,allow
Allow from all
</Directory>
</VirtualHost>
并且/home/user/workspace/project/project/wsgi.py具有以下内容:
import os
os.environ.setdefault("DJANGO_SETTINGS_MODULE", "project.settings")
from django.core.wsgi import get_wsgi_application
application = get_wsgi_application()
# import sys
# sys.path.append('~/workspace/project/project/')
# import django.core.handlers.wsgi
# application = django.core.handlers.wsgi.WSGIHandler()
跑了:
sudo a2ensite example.com
sudo /etc/init.d/apache2 reload
当我从浏览器运行example.com时,它说:“糟糕!Google Chrome无法找到example.com”。 我甚至尝试在python路径中添加项目根目录。我在这里做错了什么?