This is an Amazon Lightsail implementation of an Udacity Full-Stack Web Developer Nanodegree Project:Linux Server Configuration.
You can access the project at http://52.79.156.71.xip.io/
-
website: http://52.79.156.71.xip.io/
-
public ip: 52.79.156.71
-
port: 2200
-
user: grader
-
password: grader
-
key file:
provided within submission
-
Example connection:
ssh -i [path to key file] grader@52.79.156.71 -p 2200
-
sudo adduser grader
-
Add grader's sudo permissions into sudoer's file. Open file
sudo visudo
and pastegrader ALL=(ALL:ALL) ALL
there right under#User privilege specification
. -
Add grader user to sudoers. Open file
sudo nano /etc/sudoers.d/grader
and pastegrader ALL=(ALL:ALL) ALL
there. -
Create
.ssh
directory for grader.sudo mkdir /home/grader/.ssh
, copy content fromsudo vi /home/ubuntu/.ssh/authorized_keys
intosudo vi /home/grader/.ssh/authorized_keys
-
Try to login via
ssh -i [path to key file] grader@[ip-of-the-machine]"
-
Update port from
22
to2200
in/etc/ssh/sshd_config
. -
sudo service ssh restart
-
Set following Amazon Lightsail:
-
Check you have set that right via new ssh connection
ssh -i [path to key file] grader@[ip-of-the-machine] -p 2200
-
Update configurations to defaults via
sudo ufw default deny incoming
andsudo ufw default allow outgoing
-
Allowing connections for SSH (port 2200), HTTP (port 80), and NTP (port 123):
sudo ufw allow 2200/tcp
sudo ufw allow 80/tcp
sudo ufw allow 123/udp
-
sudo ufw show added
to check that everything is set up right. -
Turn on the fw on
sudo ufw enable
. -
Check everything is set correct via
sudo ufw status
.
sudo apt-get update
sudo apt-get upgrade
-
Install Apache
sudo apt-get install apache2
. -
Install the libapache2-mod-wsgi package
sudo apt-get install python-setuptools libapache2-mod-wsgi
-
Install PostgreSQL
sudo apt-get install postgresql
-
Restart Apache
sudo service apache2 restart
-
Install git
sudo apt-get install git
-
Install python 2.7
sudo apt-get install python-pip
sudo vim /etc/postgresql/9.5/main/pg_hba.conf
and check if remote connections are prohibited
sudo su - postgres
psql
postgres=# CREATE DATABASE sellingsocks;
postgres=# CREATE USER socks;
postgres=# ALTER ROLE socks WITH PASSWORD 'loveforsocks';
postgres=# GRANT ALL PRIVILEGES ON DATABASE sellingsocks TO socks;
\q
exit
- Preparing the project
mkdir /var/www/SellingSocks
cd /var/www/SellingSocks
sudo git clone -b postgre https://github.com/MadinaB/SellingSocks
cd SellingSocks
sudo mv application.py __init__.py
Update last line of __init__.py
from app.run(host='0.0.0.0', port=8000) to app.run()
-
Run
sudo pip install -r requirements.txt
-
sudo apt-get -qqy install postgresql python-psycopg2
-
sudo python populate_socks_db.py
-
Create file with project's virtual host configurations
sudo nano /etc/apache2/sites-available/SellingSocks.conf
-
Copy this configuration into the file:
<VirtualHost *:80>
ServerName SellingSocks
ServerAdmin madinacodes@gmail.com
ErrorLog ${APACHE_LOG_DIR}/error.log
CustomLog ${APACHE_LOG_DIR}/access.log combined
WSGIScriptAlias / /var/www/SellingSocks/sellingsocks.wsgi
Alias /static /var/www/SellingSocks/SellingSocks/static
<Directory /var/www/SellingSocks/>
Order allow,deny
Allow from all
</Directory>
<Directory /var/www/SellingSocks/SellingSocks/static/>
Order allow,deny
Allow from all
</Directory>
</VirtualHost>
- Create the .wsgi file -
sudo vi /var/www/SellingSocks/sellingsocks.wsgi
- Copy this code into the file:
#!/usr/bin/python
import sys
import logging
logging.basicConfig(stream=sys.stderr)
sys.path.append("/var/www/SellingSocks/")
from SellingSocks import app as application
application.secret_key = 'justsoooosecret'
Create static ip for your virtual machine and update host information on google developers console, then update client_secrets.json with new secrets.
Finally,
sudo apache2ctl restart
sudo a2ensite SellingSocks
You can see an error log in following file -/var/log/apache2/error.log
Go to see the socks!
Udacity Full-Stack Web Developer Nanodegree Configuring Linux Web Servers