将 Django 1.11 项目移动到 wsgi

Move Django 1.11 project to wsgi

请帮忙,我能找到错误。 我正在使用 django 1.11 和 apache(在 centos 上)

有我的wsgi.py

import os
import sys    
os.environ.setdefault("DJANGO_SETTINGS_MODULE", "project.settings")
activate_this = os.path.expanduser("/var/project/project_python35_venv/bin/activate_this.py")
execfile(activate_this, dict(__file__=activate_this))
from django.core.wsgi import get_wsgi_application
application = get_wsgi_application()

我的django.conf(httpd)

WSGILazyInitialization On
WSGIRestrictEmbedded On
WSGIPassAuthorization On

WSGIDaemonProcess project user=apache group=apache processes=10 threads=10 maximum-requests=10000 python-path=/var/project/project_python35_venv/lib/python3.5/site-packages python-home=/var/project/project_python35_venv/lib/python3.5
#WSGIProcessGroup project
#WSGIApplicationGroup %{GLOBAL}
#WSGIPythonHome /var/project/project_python35_venv/lib/python3.5

<VirtualHost *:80>

<Directory /var/project/project_python35_venv>
    Require all granted
</Directory>

CustomLog /var/log/httpd/project-access.log common
ErrorLog /var/log/httpd/project-error.log

DocumentRoot /var/project/project/project/

WSGIScriptAlias / /var/project/project/project/wsgi.py

Alias /static /var/project/project/project/static/

<Directory /var/project/project/project/static>
    Require all granted
</Directory>

<Directory /var/project/project>
    <Files wsgi.py>
        Require all granted
    </Files>
</Directory>

</VirtualHost>

我尝试了所有情况,但我的 httpd 日志中仍然出现此错误:

ImportError: No module named site

谢谢大家的帮助

试试这个

wsgi

import os
import sys

PROJECT_DIR = '/var/project'
os.environ.setdefault("DJANGO_SETTINGS_MODULE", "project.settings")
def execfile(filename):
     globals = dict( __file__ = filename )
     exec( open(filename).read(), globals )

activate_this = os.path.join( PROJECT_DIR, 'project_python35_venv/bin', 'activate_this.py' )
execfile( activate_this )

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

和apache.conf

WSGILazyInitialization On
WSGIRestrictEmbedded On
WSGIPassAuthorization On

WSGIDaemonProcess project python-path=/var/project/project/:/var/project_python35_venv/lib/python3.5/site-packages/
WSGIProcessGroup project

<VirtualHost *:80>

<Directory /var/project/project_python35_venv>
    Require all granted
</Directory>

CustomLog /var/log/httpd/project-access.log common
ErrorLog /var/log/httpd/project-error.log

DocumentRoot /var/project/project/

WSGIScriptAlias / /var/project/project/wsgi.py

Alias /var/project/project/static /var/project/project/static/

<Directory /var/project/project/static>
    Require all granted
</Directory>

<Directory /var/project>
    <Files wsgi.py>
        Require all granted
    </Files>
</Directory>

</VirtualHost>