【发布时间】:2021-04-28 21:07:14
【问题描述】:
在 apache2/ubuntu 上运行我的网站时出现以下错误:
ModuleNotFoundError: No module named 'FlaskApp'
[Sun Jan 24 23:04:52.381039 2021] [wsgi:error] [pid 25239] [client 190.160.166.19:49593] mod_wsgi (pid=25239): Target WSGI script '/var/www/FlaskApp/flaskapp.wsgi' cannot be loaded as Python module., referer: https://www.publimundo.cl/
[Sun Jan 24 23:04:52.381091 2021] [wsgi:error] [pid 25239] [client 190.160.166.19:49593] mod_wsgi (pid=25239): Exception occurred processing WSGI script '/var/www/FlaskApp/flaskapp.wsgi'., referer: https://www.publimundo.cl/
[Sun Jan 24 23:04:52.381163 2021] [wsgi:error] [pid 25239] [client 190.160.166.19:49593] Traceback (most recent call last):, referer: https://www.publimundo.cl/
[Sun Jan 24 23:04:52.381180 2021] [wsgi:error] [pid 25239] [client 190.160.166.19:49593] File "/var/www/FlaskApp/flaskapp.wsgi", line 7, in <module>, referer: https://www.publimundo.cl/
[Sun Jan 24 23:04:52.381185 2021] [wsgi:error] [pid 25239] [client 190.160.166.19:49593] from FlaskApp import app as application, referer: https://www.publimundo.cl/
这是我的虚拟主机配置:
<VirtualHost *:443>
ServerAdmin admin@publimundo.cl
ServerName www.publimundo.cl
WSGIScriptAlias / /var/www/FlaskApp/flaskapp.wsgi
SSLEngine on
SSLOptions +FakeBasicAuth +ExportCertData +StrictRequire
SSLProtocol all -SSLv2 -SSLv3
Timeout 300
KeepAlive On
MaxKeepAliveRequests 0
KeepAliveTimeout 20
ErrorLog /var/log/site_logs/publimundo-error.log
CustomLog /var/log/site_logs/publimundo-access.log combined
<Directory "/var/www/FlaskApp">
AllowOverride All
Allow from All
Require all granted
Options +FollowSymLinks
</Directory>
Alias /static /var/www/FlaskApp/publimundo/static
<Directory "/var/www/FlaskApp/publimundo/static">
AllowOverride All
Allow from All
Require all granted
Options +FollowSymLinks
</Directory>
#Include /etc/letsencrypt/options-ssl-apache.conf
SSLCertificateFile /etc/letsencrypt/live/publimundo.cl/fullchain.pem
SSLCertificateKeyFile /etc/letsencrypt/live/publimundo.cl/privkey.pem
</VirtualHost>
flaskapp.wsgi 的内容也是:
#!/usr/bin/python
import sys
import logging
logging.basicConfig(stream=sys.stderr)
sys.path.insert(0,"/var/www/FlaskApp/")
from FlaskApp import app as application
application.secret_key = 'some secret key here'
问题的根源是什么?我在 stackoverflow 上尝试了很多答案,但没有帮助。
【问题讨论】:
标签: flask apache2 mod-wsgi wsgi