在Apache2上设置Wordpress和Flask [英] Setting up Wordpress and Flask on Apache2
问题描述
我正在学习烧瓶,并且可以通过互联网访问它,因此可以使用"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:
app:
from flask import Flask
app = Flask(__name__)
@app.route('/')
def homepage():
return "Flask works?"
if __name__ == "__main__":
app.run()
conf:
#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.
- Flask和Wordpress应该在不同的端口上吗?
- 我该如何配置apache2以允许我通过flask.example.com访问flask"?
- 我已阅读到我可能需要调整主机文件.这是真的吗?
我意识到,这可能是其中一些人的明显解决方案.但是,我是一个新手,很固执.任何和所有帮助,不胜感激.
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屋!