【问题标题】:How to deploy Flask project on Plesk subdomain如何在 Plesk 子域上部署 Flask 项目
【发布时间】:2020-01-10 08:25:42
【问题描述】:

我想问是否有办法将我的 Flask 项目部署到 Plesk 子域。该站点将在 Plesk 中使用 wordpress 创建。另外,我想有数据库支持。

【问题讨论】:

    标签: wordpress flask plesk


    【解决方案1】:

    我正在努力解决类似的问题。我所做的如下:

    • 已安装 nginx
    • 在子域 -> Apache & nginx 设置中,确保在 nginx 设置下禁用代理模式
    • 将以下内容添加到附加 nginx 指令中:

      location / {
          # Define the location of the proxy server to send the request to
          proxy_pass http://127.0.0.1:5000;
      
          # Redefine the header fields that NGINX sends to the upstream server
          proxy_set_header Host $host;
          proxy_set_header X-Real-IP $remote_addr;
          proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
      
          # Define the maximum file size on file uploads
          client_max_body_size 5M;
      }
      
      
      location /static/ {
          alias /var/www/vhosts/PATH/TO/FLASK/app/static/;
      }
      

    剩下的由 gunicorn 处理,你可以在这里找到一个很棒的教程:https://blog.miguelgrinberg.com/post/the-flask-mega-tutorial-part-xvii-deployment-on-linux

    希望对你有帮助

    【讨论】:

    • 非常感谢回复,nginx必须安装在plesk里面?另外,我将如何将项目放在子域上?
    • 是的,您可以按照以下说明进行操作:support.plesk.com/hc/en-us/articles/… 要将其放置在子域中,只需通过 plesk 创建一个并将您的烧瓶项目放入其中。
    猜你喜欢
    • 2019-10-20
    • 1970-01-01
    • 1970-01-01
    • 2023-03-03
    • 2019-05-08
    • 1970-01-01
    • 2020-10-30
    • 2016-08-30
    • 2015-07-10
    相关资源
    最近更新 更多