【发布时间】:2014-07-14 12:42:54
【问题描述】:
我是 Django 部署的新手,我实际上正在尝试在我的服务器中部署我的第一个应用程序,但我想在子域中执行此操作,并且将来在其他子域中部署更多应用程序。
是否有针对 Django 1.6 执行此操作的指南?
我看过很多关于使用 mod_wsgi 部署 Django 的博客,但都太旧了(2010、2011、2012 等),并且只适用于部署一个应用程序。
我也看到有些人使用虚拟主机而其他人使用没有虚拟主机的 httpd 配置,这让我很困惑。
如果我使用 GUnicorn 和 Nginx 会更容易吗?
哪种解决方案更好?
Centos 6.5
Python 2.7
Django 1.6.2
这是我的配置不起作用:
httpd.conf
NameVirtualHost *:80
holding.conf
<VirtualHost *:80>
ServerName www.myserver.com
ServerAlias www.myserver.com/holding
DocumentRoot /var/www/html/holding/src
ErrorLog /var/www/html/holding/log/holding.log
CustomLog /var/www/html/holding/log/access.log combined
ServerAdmin helio.gutierrez@myserver.com
WSGIScriptAlias / /var/www/html/holding/src/wsgi.py
Alias /robots.txt /var/www/html/holding/src/robots.txt
Alias /favicon.png /var/www/html/holding/src/static/ico/favicon.png
Alias /static/admin/ /usr/local/lib/python2.7/site-packages/django/contrib/admin/static/admin
Alias /static/ /var/www/html/holding/src/static
Alias /media/ /var/www/html/holding/src/media
<Directory /var/www/html/holding/src>
Order allow,deny
Allow from all
</Directory>
<Directory /var/www/html/holding/src/media>
Order deny,allow
Allow from all
</Directory>
<Directory /var/www/html/holding/src/static>
Order deny,allow
Allow from all
</Directory>
</VirtualHost>
wsgi.py
import os, sys
sys.path.append('/usr/local/lib/python2.7')
sys.path.append('/usr/local/lib/python2.7/site-packages/django')
sys.path.append('/var/www/html/holding')
sys.path.append('/var/www/html/holding/src')
os.environ.setdefault("DJANGO_SETTINGS_MODULE", "src.settings")
#from django.core.wsgi import get_wsgi_application
#application = get_wsgi_application()
from django.core.handlers.wsgi import WSGIHandler
application = WSGIHandler()
【问题讨论】:
标签: python django apache nginx subdomain