【发布时间】:2020-06-02 00:19:32
【问题描述】:
我想在共享主机上部署我的 flask-restx 应用程序。由于我是部署的初学者,因此我遵循了 youtube 上的视频教程。 我是按照这个tutorial一步一步做的。 对于那些不想通过教程的人,我正在编写步骤:
- 我从 Python cPanel 创建了一个应用程序 Initial set up in Cpanel
- 然后我打开终端并通过“pip install flask”更改了我的 venv 并安装了烧瓶
- 项目结构
filas_folder/
├──public
├──tmp
│ └──restart.txt
├──app.py
└──passenger_wsgi.py
app.py 看起来像
from flask import Flask
app = Flask(__name__)
@app.route("/")
def main_():
return "flask is running"
@app.route("/user")
def main_2():
return "user is running"
if __name__ == "__main__": app.run()
- 从 cpanel 重启应用
passenger.py 看起来像
import imp
import os
import sys
sys.path.insert(0, os.path.dirname(__file__))
wsgi = imp.load_source('wsgi', 'app.py')
application = wsgi.app
当我打开 www.example.com
flask is running
但是当我打开 www.example.com/user
Internal Server Error
The server encountered an internal error or misconfiguration and was unable to complete your request.
Please contact the server administrator at webmaster@example.com to inform them of the time this error occurred, and the actions you performed just before this error.
More information about this error may be available in the server error log.
Additionally, a 500 Internal Server Error error was encountered while trying to use an ErrorDocument to handle the request.
我的系统有 cloudlinux 并使用 apache 服务器。这不是第一次部署。许多 wordpress 和静态网站都在服务器上运行。 我在 /usr/local/apache/logs/error_log 打开了 apache 日志 我收到错误“由于可能的配置错误,请求超出了 10 个内部重定向的限制。如有必要,请使用 'LimitInternalRecursion' 增加限制。使用 'LogLevel debug' 获取回溯。引用者“http://example.com/user”
【问题讨论】:
-
我会将下面答案中的链接转换为重复提案关闭投票。但是,请在同意我之前仔细检查。 ;-)
标签: python flask cpanel web-deployment mod-wsgi