2015-07-01 136 views
2

经过几天的尝试,我无法使用mod_wsgi部署我的django网站。有人能否理智地检查这些细节,看看有什么明显的错误?这是我的第一个Django部署。它已运行文件与Python manage.py runserver 10.10.10.214:8080,但我不能在/home/user/django/mysite部署无法使用mod_wsgi&apache部署django

wsgi.py文件(也是在我的settings.py等都)

""" 
WSGI config for myproject project. 

It exposes the WSGI callable as a module-level variable named ``application``. 

For more information on this file, see 
https://docs.djangoproject.com/en/1.7/howto/deployment/wsgi/ 
""" 

import os 
os.environ.setdefault("DJANGO_SETTINGS_MODULE", "mysite.settings") 

from django.core.wsgi import get_wsgi_application 
application = get_wsgi_application() 

我的Apache .conf文件:

LoadModule wsgi_module /home/conf/apache2/modules/mod_wsgi.so #dont read into the locations too much - they are correct 

WSGIScriptAlias//home/user/django/mysite/wsgi.py 
WSGIPythonPath /home/user/django 

<Directory /home/user/django/mysite> 
<Files wsgi.py> 
Require all granted 
</Files> 
</Directory> 

我不得不使用一个预先定制好的apache版本,但是上面的conf文件包含在内。任何帮助都很好。

干杯,亚瑟

+0

我推荐使用nginx和uwsgi进行部署;)http://www.django-tips.com/tip/deploying-django-project-with-nginx-and-uwsgi/3/ – doniyor

+1

apache错误日志点你在任何方向。配置似乎乍一看 –

+0

我可能只需要看看那个@ doniyor –

回答

2

试试这个wsgi.py:

import os 
import sys 

os.environ["DJANGO_SETTINGS_MODULE"] = "mysite.settings" 

sys.path.append('/home/user/django/mysite/') 
sys.path.append('/home/user/django/') 

from django.core.wsgi import get_wsgi_application 
application = get_wsgi_application() 

而别名之前添加到您的conf,:

WSGIDaemonProcess <process_name> processes=2 threads=15 user=<username> display-name=%{GROUP} 
WSGIProcessGroup <process_name> 

进程名称可能是“mysite的。 com“或其他。用户是Linux用户。

+0

罗布 - 我是否可以正确说可以是任何东西?当然有逻辑。此外,我相信离开用户= 将使用默认的Apache儿童权限 –

+0

亚瑟,你可能是正确的这两件事情。例如,我使用'user = www-data'。 –

相关问题