简体   繁体   English

无法使用 mod_wsgi 和 apache 部署 django

[英]Unable to deploy django with mod_wsgi & apache

I'm unable to deploy my django site using mod_wsgi after aa few frustrating days of trying.经过几天令人沮丧的尝试后,我无法使用 mod_wsgi 部署我的 django 站点。 Could someone sanity check these details and see if there's anything obviously wrong?有人可以理智地检查这些细节,看看是否有任何明显的错误吗? This is my first Django deployment.这是我的第一个 Django 部署。 Its been running file with python manage.py runserver 10.10.10.214:8080 but I cannot deploy它一直在使用 python manage.py runserver 10.10.10.214:8080运行文件,但我无法部署

my wsgi.py file in /home/user/django/mysite (also where my settings.py etc are)我在/home/user/django/mysite 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()

my apache .conf file:我的 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>

I am forced to use a heavily pre-customized version of apache but the conf file above is included.我被迫使用大量预先定制的 apache 版本,但包含上面的 conf 文件。 Any help at all would be great.任何帮助都会很棒。

Cheers, Arthur干杯,亚瑟

Try this wsgi.py:试试这个 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()

And add this to your conf, before the alias:并将其添加到您的 conf 中,在别名之前:

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

The process name could be "mysite.com" or whatever.进程名称可以是“mysite.com”或其他任何名称。 The user is a Linux user.用户是Linux用户。

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

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