在 Apache2 上设置 Wordpress 和 Flask [英] Setting up Wordpress and Flask on Apache2

查看:29
本文介绍了在 Apache2 上设置 Wordpress 和 Flask的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在学习 Flask 并获得了hello world"教程,因为我可以从互联网上访问它.然后我安装了 wordpress 并很快了解到使用我当前的配置无法从 example.com 访问两者.现在,我只能访问 wordpress.我尝试将烧瓶更改为 www.example.com/flask/之类的内容,但无法访问测试页面.

Im learning flask and got the "hello world" tutorial to work as I was able to access it from the internet. I then installed wordpress and soon learned that both couldn't be accessible from example.com with my current configuration. Right now, I'm only able to access wordpress. I tried changing flask to things like www.example.com/flask/ but was not able to access the test page.

我的flask和apache2配置文件如下:

My config files for flask and apache2 are as follows:

应用:

from flask import Flask

app = Flask(__name__)

@app.route('/')
def homepage():
    return "Flask works?"


if __name__ == "__main__":
    app.run()

配置:

#Listen 80
ServerName www.example.com

<VirtualHost *:80>

    ServerAdmin webmaster@localhost
    #ServerName example.com

    WSGIDaemonProcess flask user=www-data group=www-data threads=5 python-path=/var/www/FlaskApp

    WSGIScriptAlias / /var/www/FlaskApp/flaskapp.wsgi
    <Directory "/var/www/FlaskApp/">
        WSGIProcessGroup flaskapp
        WSGIApplicationGroup %{GLOBAL}
        Order deny,allow
        Allow from all
    </Directory>

    ErrorLog ${APACHE_LOG_DIR}/error.log
    CustomLog ${APACHE_LOG_DIR}/access.log combined
</VirtualHost>

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 = "secretstuff"

然后我安装了 WordPress 并意识到它们都在端口 80 上.结果,我无法访问我的 Flask 测试页面.

Then I installed WordPress and realized that they were both on port 80. As a result, I couldn't reach my Flask test page.

  1. Flask 和 Wordpress 应该在不同的端口上吗?
  2. 我将如何配置 apache2 以允许我通过flask.example.com访问flask"?
  3. 我了解到我可能需要调整我的主机文件.这是真的吗?

我意识到这对你们中的一些人来说可能是一个明显的解决方法.尽管如此,我是一个新手并且被卡住了.任何和所有的帮助表示赞赏.

I realize that this may be an obvious fix to some of you out there. Nevertheless, I'm a novice and stuck. Any and all help is appreciated.

谢谢

推荐答案

除了我更正的代码中的几个错误(没有正确指出),主要问题是改变

Aside from a couple of mistakes in the code I corrected ( wasn't pointed correctly), the main issue was changing

app.run()

app.run(host='0.0.0.0')

不知道这样做是否安全...

No clue if this is a secure thing to do or not...

这篇关于在 Apache2 上设置 Wordpress 和 Flask的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆