setting file
/var/www/html/flask
- Hello.py
- test.wsgi
/etc/apache2/sites-available
- wsgi.conf
First of all, the script itself.
Hello.py
from flask import Flask
app = Flask(__name__)
@app.route('/')
def index():
return 'Hello'
if __name__ == '__main__':
app.run()
Then create a WSGI file.
test.wsgi
import sys, site
sys.path.insert(0, '/var/www/html/flask')
from Hello import app as application
Settings on the Apache side.
# wsgi.conf
<VirtualHost *:80>
serverName (IP address or domain name of the contracted server)
WSGIDaemonProcess test user=(User name to execute Python) group=(Group of users) threads=5
WSGIScriptAlias / /var/www/html/flask/test.wsgi
<Directory /var/www/html/flask>
WSGIProcessGroup test
WSGIApplicationGroup %{GLOBAL}
WSGIScriptReloading On
Require all granted
</Directory>
</VirtualHost>
Enable wsgi.conf.
$ sudo a2ensite wsgi
And restart Apache.
$ sudo service apache2 restart
Now when you visit the site you should see "Hello".
Recommended Posts