我执行了服务器更新,这破坏了python-django网站。 修复了一些问题,但我仍然遇到一个问题,即服务器仅显示目录内容。'wsgi.py'无法正确加载。
查看错误日志,似乎在尝试加载wsgi.py时失败。
“目标WSGI脚本'/home/user/website.company.com/company/company/wsgi.py'无法作为Python模块加载。”
我花了一天时间,无法超越这一点。 谁能看到为什么会这样?
详细信息++++++++++++++++++++++++++++++
Ubuntu 16.04
Apache 2.4.18
python 2.7.12
Django 1.9.7
/etc/apache2/sites-available/000-default.conf
ServerName website.crytallise.com
ServerAdmin webmaster@company.com
ServerAlias website.company.com
DocumentRoot /home/user/website.company.com/company/company
WSGIDaemonProcess company python-path=/home/user/website.company.com/company/company:python-path=/home/user/.virtualenvs/compweb/lib/python2.7/site-packages
WSGIProcessGroup company
WSGIScriptAlias / /home/user/website.company.com/company/company/wsgi.py
Alias /static /home/user/website.company.com/static
<Directory /home/user/website.company.com/static>
Require all granted
</Directory>
<Directory /home/user/website.company.com/company/company/static>
Require all granted
</Directory>
<Directory /home/user/website.company.com/company/company/>
Options Indexes FollowSymLinks MultiViews
AllowOverride None
Require all granted
<Files wsgi.py>
Require all granted
</Files>
</Directory>
ErrorLog ${APACHE_LOG_DIR}/error.log
CustomLog ${APACHE_LOG_DIR}/access.log combined
/home/user/website.company.com/company/company.wsgi.py
import os, sys
sys.path.append("/home/user/website.company.com/company")
sys.path.append("/home/.virtualenvs/compweb/lib/python2.7/site-packages")
os.environ.setdefault("DJANGO_SETTINGS_MODULE", "company.settings")
from django.core.wsgi import get_wsgi_application
application = get_wsgi_application()
/var/log/apache2/error.log
[Sun Jun 24 14:42:08.547069 2018] [wsgi:error] [pid 3794:tid 140228412733184] [remote 00.111.222.33:12345] mod_wsgi (pid=3794): Target WSGI script '/home/user/website.company.com/company/company/wsgi.py' cannot be loaded as Python module.
[Sun Jun 24 14:42:08.547117 2018] [wsgi:error] [pid 3794:tid 140228412733184] [remote 00.111.222.33:12345] mod_wsgi (pid=3794): Exception occurred processing WSGI script '/home/user/website.company.com/company/company/wsgi.py'.
[Sun Jun 24 14:42:08.547143 2018] [wsgi:error] [pid 3794:tid 140228412733184] [remote 00.111.222.33:12345] Traceback (most recent call last):
[Sun Jun 24 14:42:08.547172 2018] [wsgi:error] [pid 3794:tid 140228412733184] [remote 00.111.222.33:12345] File "/home/user/website.company.com/company/company/wsgi.py", line 18, in <module>
[Sun Jun 24 14:42:08.547211 2018] [wsgi:error] [pid 3794:tid 140228412733184] [remote 00.111.222.33:12345] from django.core.wsgi import get_wsgi_application
[Sun Jun 24 14:42:08.547236 2018] [wsgi:error] [pid 3794:tid 140228412733184] [remote 00.111.222.33:12345] ImportError: No module named django.core.wsgi
[Sun Jun 24 14:43:04.536822 2018] [mpm_event:notice] [pid 3791:tid 140228634376064] AH00491: caught SIGTERM, shutting down
[Sun Jun 24 14:43:05.600979 2018] [wsgi:warn] [pid 6095:tid 140317469992832] mod_wsgi: Compiled for Python/2.7.11.
[Sun Jun 24 14:43:05.601031 2018] [wsgi:warn] [pid 6095:tid 140317469992832] mod_wsgi: Runtime using Python/2.7.12.
[Sun Jun 24 14:43:05.601925 2018] [mpm_event:notice] [pid 6095:tid 140317469992832] AH00489: Apache/2.4.18 (Ubuntu) mod_wsgi/4.3.0 Python/2.7.12 configured -- resuming normal operations
[Sun Jun 24 14:43:05.601946 2018] [core:notice] [pid 6095:tid 140317469992832] AH00094: Command line: '/usr/sbin/apache2'