我想使用 wsgi 在我的 ubuntu 服务器上为 apache 设置我的 Flask 应用程序。但设置后,我收到以下浏览器错误:
Not Found
The requested URL / was not found on this server.
apache 错误日志抛出:
Target WSGI script not found or unable to stat:
/var/www/html/appname/appname.wsgi
我的 wsgi 文件如下所示:
#!/usr/bin/python
import sys
import logging
logging.basicConfig(stream=sys.stderr)
sys.path.insert(0,"/var/www/html/appname/")
from IdeaHound import app as application
application.secret_key = 'here_the_key'
我的 apache 配置文件如下所示:
<VirtualHost *:80>
ServerName server_ip_here
WSGIScriptAlias / /var/www/html/appname/appname.wsgi
<Directory /var/www/html/appname/>
Order allow,deny
Allow from all
</Directory>
ErrorLog ${APACHE_LOG_DIR}/error.log
LogLevel info
CustomLog ${APACHE_LOG_DIR}/access.log combined
</VirtualHost>
appname 文件夹具有以下结构: 应用程序名称
--application.py
--appname.wsgi
--LICENSE
--README.md
--requirements.txt
--db_manage.py
--appname
----frontend
----__inity__.py
----__init__.pyc
----models
----__pycache__
----socket_interface
--AppName
----__init__.py
----static
----templates
--instance
----config.py
为了让 Web 服务器与 Flask 一起正确运行,我缺少什么?
最佳答案
请阅读以下 digital ocean 链接。按照其中的描述进行操作。您的应用程序将在短短 5 分钟内启动并运行。
https://www.digitalocean.com/community/tutorials/how-to-deploy-a-flask-application-on-an-ubuntu-vps
如果仍然抛出错误,还请检查 apache 错误日志以获取更多信息。
/var/log/apache2/error.log
关于python - 为什么 apache 会抛出“目标 WSGI 脚本未找到或无法在 Flask 应用程序上进行统计”?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/35044650/