我得到这个 eror :
sudo service apache2 restart :
[Thu Apr 18 13:11:02.687353 2019] [mpm_event:notice] [pid 2135:tid 140232732096384] AH00491: caught SIGTERM, shutting down
[Thu Apr 18 13:11:03.694739 2019] [ssl:warn] [pid 2300:tid 139990910658432] AH01909: ip-*.*.*.*.ec2.internal:443:0 server certificate does NOT include an ID which matches the server name
[Thu Apr 18 13:11:03.702921 2019] [ssl:warn] [pid 2301:tid 139990910658432] AH01909: ip-*.*.*.*.ec2.internal:443:0 server certificate does NOT include an ID which matches the server name
[Thu Apr 18 13:11:03.703014 2019] [wsgi:warn] [pid 2301:tid 139990910658432] mod_wsgi: Compiled for Python/2.7.11.
[Thu Apr 18 13:11:03.703018 2019] [wsgi:warn] [pid 2301:tid 139990910658432] mod_wsgi: Runtime using Python/2.7.12.
然后我输入了我们网站的域并进入了/var/log/apache2/error.log:
[Thu Apr 18 13:11:03.703598 2019] [mpm_event:notice] [pid 2301:tid 139990910658432] AH00489: Apache/2.4.18 (Ubuntu) OpenSSL/1.0.2g mod_wsgi/4.3.0 Python/2.7.12 configured -- resuming normal operations
[Thu Apr 18 13:11:03.703617 2019] [core:notice] [pid 2301:tid 139990910658432] AH00094: Command line: '/usr/sbin/apache2'
[Thu Apr 18 13:11:10.014862 2019] [wsgi:error] [pid 2304:tid 139990600201984] err : No module named boto
[Thu Apr 18 13:11:10.015214 2019] [wsgi:error] [pid 2304:tid 139990600201984] [client 81.218.184.134:30333] mod_wsgi (pid=2304): Target WSGI script '/home/ubuntu/path/to/my_project/src/my_project/wsgi.py' does not contain WSGI application 'application'.
我正在使用 Ubuntu 16.0.4 Apache2 并在 AWS EC2 上nod_wsgi,开始启动正在运行的项目(不是新项目(
在我的 wsgi.py 中打印异常,我得到:
No module named boto from
try:
application = get_wsgi_application()
except Exception as e:
print "err : {}".format(e)
但我有 boto 安装:
# pip freeze | grep boto
You are using pip version 8.1.1, however version 19.0.3 is available.
You should consider upgrading via the 'pip install --upgrade pip' command.
boto==2.49.0
boto3==1.9.112
botocore==1.12.16
以下是我根据 https://docs.djangoproject.com/en/2.2/topics/install/配置的其他文件: # cat/etc/apache2/mods-enabled/wsgi.load LoadModule wsgi_module/usr/lib/apache2/modules/mod_wsgi.so
# cat /etc/apache2/mods-enabled/wsgi.conf
<IfModule mod_wsgi.c>
WSGIPassAuthorization on
WSGIScriptAlias / /home/ubuntu/path/to/wsgi.py
WSGIPythonPath /home/ubuntu/path/to/my_project
<VirtualHost *:80>
<Directory "/home/ubuntu/path/to//my_project/">
Require all granted
</Directory>
</VirtualHost>
..
</IfModule>
看起来您可能缺少WSGIPythonPath
指令中的site-packages
目录。我通常将 python 路径定义为 WSGIDaemonProcess
指令的一部分:
WSGIDaemonProcess example
display-name=example
processes=2 threads=20
maximum-requests=10000
umask=0002
python-path=${SRV}/www:${SRV}/src:${SRV}/venv/prod_142/lib/python2.7/site-packages
python-eggs=${SRV}/.python-eggs
WSGIScriptAlias / ${SRV}/www/example/wsgi.py
process-group=example
application-group=%{GLOBAL}
您可以在自述文件中看到功能更全的虚拟主机定义 https://github.com/datakortet/dkbuild-apacheconf (我是作者(。
问题是并非所有的 Python 软件包都已安装,安装所有缺少的软件包后,网站可以正常工作