You will take a baseline installation of a Linux distribution on a virtual machine and prepare it to host your web applications, to include installing updates, securing it from a number of attack vectors and installing/configuring web and database servers.
IP Address: 18.221.61.38
SSH Port: 2200
Application URL: http://18.221.61.38
Ubuntu
Finger
Apache2
Libapache2-Mod-Wsgi
PostgreSQL
Flask
SQL Alchemy
HttpLib2
OAuth2Client
Requests
sudo apt-get update
sudo apt-get upgrade
sudo apt-get autoremove
sudo apt-get install finger
sudo adduser grader
sudo chmod 755 /etc/sudoers.d
sudo touch /etc/sudoers.d/grader
sudo chmod 777 /etc/sudoers.d/grader
sudo echo "grader ALL=(ALL) NOPASSWD:ALL" > /etc/sudoers.d/grader
sudo chmod 755 /etc/sudoers.d/grader
ssh-keygen
su grader
mkdir ~/.ssh
touch ~/.ssh/authorized_keys
nano ~/.ssh/authorized_keys
chmod 700 ~/.ssh
chmod 644 ~/.ssh/authorized_keys
sudo nano /etc/ssh/sshd_config
Port 2200
PermitRootLogin no
Password Authentication no
sudo service ssh restart
Networking tab -> Custom TCP 2200
sudo ufw default deny incoming
sudo ufw default allow outgoing
sudo ufw allow 2200/tcp
sudo ufw allow www
sudo ufw allow ntp
sudo ufw enable
sudo ufw status
sudo dpkg-reconfigure tzdata
sudo apt-get install apache2
Verify by going to IP address and seeing Apache2 Ubuntu Default Page
sudo apt-get install libapache2-mod-wsgi-py3
sudo apt-get install postgresql
sudo -i -u postgres
createuser --interactive -P
Answer no to all questions.
psql
CREATE DATABASE catalog;
\q
exit
sudo apt-get install git
sudo mkdir /var/www/catalog
sudo chown grader:grader /var/www/catalog
cd /var/www/catalog
sudo git clone https://github.com/lbuthman/udacity-catalog.git
sudo mv /var/www/catalog/udacity-catalog /var/www/catalog/catalog
sudo chmod 700 /var/www/catalog/catalog/.git
sudo apt-get install python3-pip
sudo -H pip3 install --upgrade pip
sudo pip3 install flask==0.12
sudo pip3 install SQLAlchemy
sudo -H pip3 install oauth2client
sudo -H pip3 install psycopg2
sudo mv project.py __init.py__
sudo nano __init__.py
change from database_setup import ... to from .database_setup import ... add absolute path to client secrets engine = create_engine('postgresql://catalog:catalog@localhost/catalog')
sudo nano database_setup.py
sudo nano lotsofexercises.py
engine = create_engine('postgresql://catalog:catalog@localhost/catalog')
sudo python database_setup.py
sudo python lotsofexercises.py
sudo -i -u postgres
postgres catalog
\dt
select * from category;
select * from exercise;
\q
exit
sudo nano /var/www/catalog/catalog.wsgi
#!/usr/bin/python import sys import logging logging.basicConfig(stream=sys.stderr) sys.path.insert(0,"/var/www/catalog/")
from catalog import app as application
sudo nano /etc/apache2/sites-available/catalog.conf
<VirtualHost *:80>
ServerName exercisedatabase.com
ServerAdmin admin@mywebsite.com
WSGIScriptAlias / /var/www/catalog/catalog.wsgi
<Directory /var/www/catalog/catalog/>
Order allow,deny
Allow from all
Alias /static /var/www/catalog/catalog/static
<Directory /var/www/catalog/catalog/static/>
Order allow,deny
Allow from all
ErrorLog
sudo nano /etc/apache2/sites-enabled/000-default.conf
Append following to the end of the file
WSGIScriptAlias / /var/www/catalog/catalog/catalog.wsgi
sudo service apache2 restart
sudo cat /var/log/apache2/error.log
nslookup 18.221.61.38
/var/www/catalog/catalog/client_secrets.json
/var/www/catalog/catalog/fb_client_secrets.json