[英]Django 1.4 using Apache Virtual Host
I'm installing django 1.4 on Apache and I intended to use the same webserver for PHP apps too. 我正在Apache上安装django 1.4,并且打算将同一Web服务器也用于PHP应用程序。 My OS is Ubuntu 12.04 LTS.
我的操作系统是Ubuntu 12.04 LTS。 If I do configurations on the main conf file, the localhost will point straight away to the Django installation page,even the PHP apps too.So I created a vhost file at /etc/apache2/sites-available and name it as 'project'.
如果我在主conf文件上进行配置,则localhost将直接指向Django安装页面,甚至包括PHP应用程序。因此,我在/ etc / apache2 / sites-available创建了一个虚拟主机文件,并将其命名为“ project” 。 However, seems to me, it fails to point to the wsgi file.
但是,在我看来,它无法指向wsgi文件。 This is my configuration:
这是我的配置:
<VirtualHost *:80>
DocumentRoot /var/www/project/
ServerName project
WSGIScriptAlias / /var/www/project/project/wsgi.py
<Directory "/var/www/project/project">
<Files wsgi.py>
Order deny,allow
Allow from all
</Files>
</Directory>
</VirtualHost>
This is my wsgi.py file: 这是我的wsgi.py文件:
import os
import sys
sys.path.append('/var/www/project')
os.environ['DJANGO_SETTINGS_MODULE'] = 'project.settings'
import django.core.handlers.wsgi
application = django.core.handlers.wsgi.WSGIHandler()
What am I missing? 我想念什么? I strongly believe it's something to do with the
<VirtualHost>
directive because it won't read the wsgi file even I intentionally do some syntax errors there and Apache doesn't detect these when I restart it. 我坚信这与
<VirtualHost>
指令有关,因为即使我故意在其中执行一些语法错误,并且我重新启动Apache时也不会检测到这些错误,它不会读取wsgi文件。
That's dumb. 真傻 I almost forgot that python will run on port 8000!
我几乎忘了python将在端口8000上运行!
I actually need to go into the first level of the project folder and run the Django development server by executing: python manage.py runserver
我实际上需要进入项目文件夹的第一级并通过执行以下命令来运行Django开发服务器:
python manage.py runserver
Thanks. 谢谢。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.