请帮助,我可以找到错误。 我使用的是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:没有名为site
的模块
谢谢大家的帮助
答案 0 :(得分:0)
试试这个
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>