Final project of Udacity Full Stack Web Developer Nanodegree
The goal of the project is to deploy Item Catalog Application as Amazon Lightsail.
The server is available by this url: http://13.59.27.59/
-
Create an account on AWS and launch an instance with Ubuntu operational system
-
Change ssh port from 22 to 2200
-
Connect to the server
chmod 400 LightsailDefaultPrivateKey-us-east-2.pem ssh ubuntu@13.59.27.59 -i LightsailDefaultPrivateKey-us-east-2.pem
-
Edit file /etc/ssh/sshd_config
Port 2200 PermitRootLogin no PasswordAuthentication yes
-
Restart ssh server:
service sshd restart
-
Change ports in firewall
-
-
Create a user grader
-
Create a new account with root permissions
sudo su - adduser grader usermod -aG sudo grader mkdir /home/grader/.ssh chown grader:grader /home/grader/.ssh chmod 700 /home/grader/.ssh cp /root/.ssh/authorized_keys /home/grader/.ssh/ chown grader:grader /home/grader/.ssh/authorized_keys chmod 644 /home/grader/.ssh/authorized_keys
-
Create ssh keys and copy to the user folder
ssh-keygen -f ssh_keys/grader cat ssh_keys/grader.pub | ssh grader@13.59.27.59 -p 2200 "cat >> ~/.ssh/authorized_keys"
-
Disable login with password in file /etc/ssh/sshd_config
PasswordAuthentication no
-
-
Configure Linux
-
Install latest software
ssh grader@13.59.27.59 -p 2200 -i ssh_keys/grader sudo apt-get -qy upgrade sudo apt-get -qy update
-
Set timezone to UTC and locale
sudo timedatectl set-timezone UTC echo 'LC_ALL="en_US.UTF-8"' >> /etc/environment source /etc/environment export LC_ALL
-
Install apache2, postgres and python
sudo apt-get install apache2 sudo apt-get install libapache2-mod-wsgi-py3 sudo apt-get install python3-pip sudo pip3 install --upgrade pip sudo pip3 install flask sudo pip3 install sqlachemy sudo pip3 install oauth2client sudo pip3 install psycopg2 sudo apt -qy install postgresql python3-psycopg2 libpq-dev
-
Setup a database
sudo -u postgres createuser -P catalog sudo -u postgres createdb -O catalog catalog
-
-
Deploy project
-
Clone project to /var/www/
cd /var/www/ git clone https://github.com/irsol/item-catalog-app.git
-
Create server.wsgi file
import sys import logging logging.basicConfig(stream=sys.stderr) sys.path.insert(0, "/var/www/item-catalog-app/") from server import app as application
-
Update /etc/apache2/sites-enabled/000-default.conf
<VirtualHost *:80> WSGIScriptAlias / /var/www/item-catalog-app/server.wsgi <directory /var/www/item-catalog-app/> WSGIApplicationGroup %{GLOBAL} Require all granted </directory> ErrorLog ${APACHE_LOG_DIR}/error.log CustomLog ${APACHE_LOG_DIR}/access.log combined </VirtualHost>
-
Change database connection from sqlite to postgres in database_setup.py
engine = create_engine('postgresql://catalog:<password>@localhost:5432/catalog')
-
Copy client_secrets.json to /var/www/item-catalog-app
-
Restart apache:
sudo apache2ctl restart
-