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.
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"
Then I installed WordPress and realized that they were both on port 80. As a result, I couldn’t reach my Flask test page.
- Should Flask and WordPress be on different ports?
- How would I go about configuring apache2 to allow me to “access flask” via flask.example.com?
- I’ve read that I possibly need to adjust my host file. Is this true?
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.
Thanks
Aside from a couple of mistakes in the code I corrected ( wasn’t pointed correctly), the main issue was changing
to
No clue if this is a secure thing to do or not…
Use Apache Name-based. In
/etc/apache2/sites-available
:flaskapp.conf
:wordpress.conf
:Reload apache confs: