Deploy Flask App to the Apache2 Web Server

Install Apache2

sudo apt install apache2

Install PHP (apabila belum ada service php)

https://linuxize.com/post/how-to-install-php-on-ubuntu-18-04/

Install Mysql Server

sudo apt install mysql-server
sudo mysql_secure_installation

Install Phpmyadmin

sudo apt install phpmyadmin

Deploy Flask

pada bagian install WSGI gunakan WSGI python versi 3 dari tutorial ini:

sudo apt-get install libapache2-mod-wsgi-py3

Dan apabila virtual env belum terinstall, bisa mengikuti tutorial ini:

Full Deploy, tapi ingat gunakan python3

Contoh Konfigurasi

ugetapp.conf (apache2)

<VirtualHost *:80>
ServerAdmin webmaster@df.hdrc.pens.ac.id
ServerName www.df.hdrc.pens.ac.id
ServerAlias df.hdrc.pens.ac.id
ErrorLog /var/www/uget/logs/error.log
CustomLog /var/www/uget/logs/access.log combined

WSGIDaemonProcess ugetapp user=www-data group=www-data threads=5
WSGIProcessGroup ugetapp
WSGIApplicationGroup %{GLOBAL}
WSGIScriptAlias / /var/www/FLASKAPPS/ugetapp/ugetapp.wsgi
Alias /static /var/www/FLASKAPPS/ugetapp/static/
<Directory /var/www/FLASKAPPS/ugetapp/static/>
Order allow,deny
Allow from all
</Directory>
</VirtualHost>

Contoh Konfigurasi Setelah di Setting HTTPS

WSGIDaemonProcess uget user=www-data group=www-data threads=5
WSGIProcessGroup uget
WSGIApplicationGroup %{GLOBAL}

<VirtualHost *:80>
ServerAdmin webmaster@df.hdrc.pens.ac.id
ServerName www.df.hdrc.pens.ac.id
ServerAlias df.hdrc.pens.ac.id
ErrorLog /var/www/uget/logs/error.log
CustomLog /var/www/uget/logs/access.log combined

WSGIScriptAlias / /var/www/FLASKAPPS/ugetapp/ugetapp.wsgi
Alias /static /var/www/FLASKAPPS/ugetapp/static/
<Directory /var/www/FLASKAPPS/ugetapp/static/>
Order allow,deny
Allow from all
</Directory>
</VirtualHost>

yang terkait dengan WSGI diletakan diluar Block port. karena akan muncul issue penggunaan nama app wsgi duplicate

--

--

Get the Medium app

A button that says 'Download on the App Store', and if clicked it will lead you to the iOS App store
A button that says 'Get it on, Google Play', and if clicked it will lead you to the Google Play store