-
Make New Directory in var/www/
mkdir bots
-
Create FILENAME.wsgi file
sudo nano bots.wsgi
-
Add this content and Save File
#! /usr/bin/python3 import sys import logging logging.basicConfig(stream=sys.stderr) sys.path.insert(0,"/home/bots/") #APPS DIRECTORY from botone import app as application # FROM APPNAME IMPORT APP AS APPLICATION
-
upload Your flask app files to the above defind apps directory
cd /home/bots/
-
Go to the below directory
cd /etc/apache2/sites-available
-
Create a new .conf file
sudo nano bots.conf
-
Add the below content
<VirtualHost *:80> ServerName harshanas.me ServerAdmin [email protected] WSGIScriptAlias /bots/bottwo /var/www/bots/bots.wsgi <Directory /home/bots/bottwo> Order allow,deny Allow from all </Directory> ErrorLog ${APACHE_LOG_DIR}/error.log LogLevel warn CustomLog ${APACHE_LOG_DIR}/access.log combined </VirtualHost>
add below lines for every app you deploy
WSGIScriptAlias /bots/botone /var/www/bots/botone.wsgi <Directory /home/bots/botone> Order allow,deny Allow from all </Directory>
-
Create a new .conf file
sudo nano bots-ssl.conf
-
Add the below content
<VirtualHost *:443> ServerName harshanas.me ServerAdmin [email protected] WSGIScriptAlias /bots/bottwo /var/www/bots/bots.wsgi <Directory /home/bots/bottwo/> Order allow,deny Allow from all </Directory> ErrorLog ${APACHE_LOG_DIR}/error.log LogLevel warn CustomLog ${APACHE_LOG_DIR}/access.log combined SSLEngine on SSLCertificateFile /etc/letsencrypt/live/harshanas.me/fullchain.pem SSLCertificateKeyFile /etc/letsencrypt/live/harshanas.me/privkey.pem Include /etc/letsencrypt/options-ssl-apache.conf </VirtualHost>
add below lines for every app you deploy
WSGIScriptAlias /bots/botone /var/www/bots/botone.wsgi <Directory /home/bots/botone> Order allow,deny Allow from all </Directory>
-
add the virtual host
sudo a2ensite bots.conf
sudo a2ensite bots-ssl.conf
Disable the virtual host
sudo a2dissite bots.conf
sudo a2dissite bots-ssl.conf
-
reload apache
service apache2 reload
Last active
September 5, 2017 08:24
-
-
Save harshanas/3e003223e7dd5b8639b8b9ea172252f6 to your computer and use it in GitHub Desktop.
Deploy Flask App to apache in Ubuntu 16.04
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment