【发布时间】:2014-06-03 17:46:20
【问题描述】:
我在配置 mod_wsgi 设置的各种元素时遇到了一些问题。这是我第一次使用 mod_wsgi,所以我一直在学习几个教程,主要的是 YouTube 视频 Install Django on Apache with mod_wsgi on Linux 。根据我在执行以下步骤后的理解,我至少应该看到 Django 'It Works' 页面。
设置
- Ubunto 12.04
- Apache 2.2.22
- Python 2.7.3
- Django 1.6
我在我的主目录中创建了一个 WSGI 脚本文件 firstweb.wsgi
/home/firstweb.wsgi
它的内容是
import os
import sys
sys.path = [‘/var/www/firstweb’] + sys.path
os.environ[‘DJANGO_SETTINGS_MODULE’] = ‘firstweb.settings’
import django.core.handlers.wsgi
application = django.core.handlers.wsgi.WSGIHandler()
然后我为位于
的项目创建了一个宿主文件/etc/apache2/sites-available/firstweb.conf
它的内容是
<VirtualHost *:80>
ServerAdmin webmaster@firstweb.com
ServerName www.firstweb.com
ServerAlias firstweb.com
WSGIScriptAlias / /home/firstweb.wsgi
Alias /static /var/www/firstweb/static/
<Directory /var/www/firstweb/>
Order allow,deny
Allow from all
</Directory>
</VirtualHost>
然后我使用命令启用配置文件
a2ensite firstweb.conf
然后我开始了我的 django 项目。
我去了 /var/www/ 并使用了 Django 启动项目命令
django-admin.py startproject firstweb
然后我重新启动了我的服务器
sudo service apache2 restart
最后,我重新配置了我的 Apache 主机文件,将域 firstweb.com 指向我新的本地 Django 项目
/etc/hosts
127.0.0.1 localhost
127.0.1.1 ubuntu
134.226.38.147 firstweb.com
所以当我访问 www.firstweb.com 时,我应该看到 Django “It Works!”。页面
谁能告诉我我做错了什么?
【问题讨论】: