Sruthi Vinukonda
Public IP: 18.221.145.45
Host name: ec2-18-221-145-45.us-east-2.compute.amazonaws.com
- Openssh Server
- Apache2
- PostgreSQL
- GIT
- mod_wsgi
- Python
- virtualenv
- Flask
- requests
- httplib2
- sqlalchemy
- psycopg2
- oauth2client
- render_template
- sqlalchemy_utils
- redirect
- Create Lightsail account and new Instance
- Connect using SSH
- Download private key
- In the Networking tab, add two new custom ports - 123 and 2200
- Place private key in .ssh
$ chmod 600 ~/.ssh/LightsailDefaultPrivateKey-us-east-2.pem
$ ssh -i ~/.ssh/LightsailDefaultPrivateKey-us-east-2.pem ubuntu@18.221.145.45
$ sudo su -
$ sudo nano /etc/sudoers.d/grader
Addgrader ALL=(ALL:ALL) ALL
$ sudo nano /etc/hosts
Under127.0.1.1:localhost
add127.0.1.1 ip-10-20-37-65
$ sudo apt-get update
$ sudo apt-get upgrade
$ sudo apt-get install finger
- In a new terminal, `$ ssh-keygen -f ~/.ssh/udacity_key.rsa
$ cat ~/.ssh/udacity_key.rsa.pub
- In the original terminal,
$ cd /home/grader
$ mkdir .ssh
$ touch .ssh/authorized_keys
$ nano .ssh/authorized_keys
- Permissions:
$ sudo chmod 700 /home/grader/.ssh
$ sudo chmod 644 /home/grader/.ssh/authorized_keys
$ sudo chown -R grader:grader /home/grader/.ssh
$ sudo service ssh restart
- To disconnect:
$ ~.
$ ssh -i ~/.ssh/udacity_key.rsa grader@18.221.145.45
$ sudo nano /etc/ssh/sshd_config
- Find the PasswordAuthentication line and change text after to
no
$ sudo service ssh restart
$ sudo nano /etc/ssh/sshd_config
- Find the Port line and change
22
to2200
$ sudo service ssh restart
$ ~.
$ ssh -i ~/.ssh/udacity_key.rsa -p 2200 grader@18.221.145.45
$ sudo nano /etc/ssh/sshd_config
- Find the PermitRootLogin line and edit to
no
$ sudo service ssh restart
$ sudo ufw allow 2200/tcp
$ sudo ufw allow 80/tcp
$ sudo ufw allow 123/udp
$ sudo ufw enable
$ sudo apt-get install apache2
$ sudo apt-get install libapache2-mod-wsgi python-dev
$ sudo apt-get install git
$ sudo a2enmod wsgi
$ sudo service apache2 start
$ cd /var/www
$ sudo mkdir catalog
$ sudo chown -R grader:grader catalog
$ cd catalog
$ git clone https://github.com/SruthiV/Item-Catalog.git catalog
$sudo nano catalog.wsgi
import sys
import logging
logging.basicConfig(stream=sys.stderr)
sys.path.insert(0, "/var/www/catalog/")
from catalog import app as application
application.secret_key = 'super_secret_key'
- Rename the application.py to init.py
$ sudo pip install virtualenv
$ sudo virtualenv venv
$ source venv/bin/activate
$ sudo chmod -R 777 venv
$ sudo apt-get -H install python-pip
$ sudo pip -h install Flask
$ sudo pip -h install Requests
$ sudo pip -h install httplib2
$ sudo pip -h install sqlalchemy
$ sudo pip -h install psycopg2
$ sudo pip -h install oauth2client
$ sudo pip -h install render_template
$ sudo pip -h install sqlalchemy_utils
$ sudo pip -h install redirect
$nano __init__.py
Change the client_secrets.json line to /var/www/catalog/catalog/client_secrets.json- Change the host to 18.221.145.45 and port to 80
$ sudo nano /etc/apache2/sites-available/catalog.conf
<VirtualHost *:80>
ServerName [18.221.145.45]
ServerAlias [ec2-18-221-145-45.us-east-2.compute.amazonaws.com]
ServerAdmin admin@18.221.145.45
WSGIDaemonProcess catalog python-path=/var/www/catalog:/var/www/catalog/venv/lib/python2.7/site-packages
WSGIProcessGroup catalog
WSGIScriptAlias / /var/www/catalog/catalog.wsgi
<Directory /var/www/catalog/catalog/>
Order allow,deny
Allow from all
</Directory>
Alias /static /var/www/catalog/catalog/static
<Directory /var/www/catalog/catalog/static/>
Order allow,deny
Allow from all
</Directory>
ErrorLog ${APACHE_LOG_DIR}/error.log
LogLevel warn
CustomLog ${APACHE_LOG_DIR}/access.log combined
</VirtualHost>
$ sudo apt-get install libpq-dev python-dev
$ sudo apt-get install postgresql postgresql-contrib
$ sudo su - postgres
$ psql
$ CREATE USER catalog WITH PASSWORD 'password';
$ ALTER USER catalog CREATEDB;
$ CREATE DATABASE catalog WITH OWNER catalog;
Connect to database$ \c catalog
$ REVOKE ALL ON SCHEMA public FROM public;
$ GRANT ALL ON SCHEMA public TO catalog;
Quit the postgres command line:$ \q
and then$ exit
$ nano __init__.py
Edit database_setup.py, and menus.py files to change the database engine fromsqlite://catalog.db
topostgresql://catalog:password@localhost/catalog
- Add
ec2-18-221-145-45.us-east-2.compute.amazonaws.com
to Authorized JavaScript Origins and Authorised redirect URIs on Google Developer Console. $ sudo service apache2 restart
https://github.com/callforsky/udacity-linux-configuration
https://github.com/mulligan121/Udacity-Linux-Configuration