A step-by-step guide to deploy a Jam.py on the AWS¶
This is adapted from https://devops.profitbricks.com/tutorials/install-and-configure-mod_wsgi-on-ubuntu-1604-1/
I hope someone finds it useful.
Create an AWS account and login
Go to EC2, create an instance (in this case an Ubuntu 16.04 t2.micro)
Download the private key when prompted
Convert pem to ppk using Puttygen (see: https://stackoverflow.com/questions/3190667/convert-pem-to-ppk-file-format)
Get EC2 instance public DNS from AWS dashboard
SSH into EC2 instance using Putty (pointed to the Public DNS and your ppk)
Username is ubuntu
Refresh package library:
sudo apt-get updateInstall pip:
sudo apt-get install python3-pipInstall jam.py:
sudo pip3 install jam.pyInstall Apache:
sudo apt-get install apache2 apache2-utils libexpat1 ssl-certInstall mod-wsgi:
sudo apt-get install libapache2-mod-wsgi-py3Restart Apache:
sudo /etc/init.d/apache2 restartMove here:
cd /var/www/html/Create directory:
sudo mkdir [appname]Move here:
cd [appname]Create app:
sudo jam-project.pyCheck it’s there:
lsCreate the config:
sudo nano /etc/apache2/conf-available/wsgi.confPaste the following
WSGIScriptAlias / /var/www/html/[appname]/wsgi.py WSGIPythonPath /var/www/html/[appname] <Directory /var/www/html/[appname]> <Files wsgi.py> Require all granted </Files> </Directory> Alias /static/ /var/www/html/[appname]/static/ <Directory /var/www/html/[appname]/static> Require all granted </Directory>
Exit and save
Give file permissions to apache:
sudo chmod 777 /var/www/html/[appname]Give ownership to apache:
sudo chown -R www-data:www-data /var/wwwEnable wsgi:
sudo a2enconf wsgiRestart apache:
sudo /etc/init.d/apache2 restartCreate security group on AWS to allow you to connect HTTP on port 80
Assign instance to security group
Test
If it’s not working, check the error logs to see what’s going on:
nano /var/log/apache2/error.log
This was initially published by Simon Cox on https://groups.google.com/forum/#!msg/jam-py/Zv5JfkLRFy4/22tolZ-hAQAJ