繁体   English   中英

无法使用apache mod WSGI在ubuntu上部署Django

[英]unable to deploy Django on ubuntu with apache mod WSGI

我正在使用ubuntu 12.04,并且执行了以下操作:

须藤apt-get install python-mysql

sudo python setup.py install(安装Django 1.6.2)

须藤apt-get install mysql-server -...

须藤apt-get install apache2

须藤apt-get install libapache2-mod-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/apache/sites-availables/firstweb.conf:

<VirtualHost *:80>
WSGIScriptAlias / /home/adel/firstweb.wsgi
ServerName firstweb.com
Alias /static /var/www/firstweb/static/

<Directory /var/www/firstweb/>
order allow,deny
Allow from all
</Directory>
</VirtualHost>

然后我做了:

  1. a2ensite firstweb.conf
  2. cd /var/www/
  3. django-admin.py startproject firstweb
  4. apachectl restart
  5. vi /etc/hosts

并添加以下内容( 192.168.0.123是我的wlan ip)

192.168.0.123 firstweb.com

我使用mysql并创建数据库并更改settings.pysyncdb正常运行

但是,当我在浏览器中输入www.firstweb.com时,将显示Apache的默认页面(有效。。。)

并且Django默认页面没有出现!

我的配置有什么问题?

谢谢。

您的虚拟服务器不在www.firstweb.com上监听,而仅在firstweb.com上监听。 您应该为www版本添加ServerAlias指令。

WSGIScriptAlisa指令所引用的路径不在您为Directory指令指定的任何目录中,该目录指示允许Apache从何处提供文件/脚本。 此外,Apache用户通常将无法访问用户主目录下的文件。 这两个问题都会导致不同的“禁止的HTTP”响应。 因此,即使您解决了ServerName / ServerAlias和主机问题,也很可能会遇到这些问题。 确保您阅读了Django网站上的官方mod_wsgi部署文档。

暂无
暂无

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM