website is hosted on Amazon lightsail Ip address: 3.121.185.127 SSH Port: 2200
follow the following steps:
- create a username grader by excuting the following command:
sudo adduser grader
- give the grader sudo access with
usermod -aG sudo grader
- Update and upgrade packages:
sudo apt update
thensudo apt upgrade
- change the SSH port :
sudo nano /etc/ssh/sshd_config
then change port number from 22 to 2200 - then restart the ssh service by:
sudo service ssh restart
4:configure the firewall to close all the ports but SSH port 2200 and HTTP port 80 and NTP port 123:
sudo ufw allow 2200/tcp
sudo ufw deny 22
sudo ufw allow 80/tcp
sudo ufw allow 123/udp
sudo ufw allow ssh
sudo ufw allow www
sudo ufw allow ftp
sudo ufw enable
- by
sudo dpkg-reconfigure tzdata
then choose none of the above then choose UTC
- Run
ssh-keygen
- save the file in /home/user/.ssh/id_rsa
- switch to grader
sudo login grader
- make ssh directory in grader
mkdir .ssh
- make authorized_keys file
touch .ssh/authorized_keys
- Give the permissions :
chmod 700 .ssh
andchmod 644 .ssh/authorized_keys.
nano /etc/ssh/sshd_config
, change PasswordAuthentication tono
- then restart the SSH service
sudo service ssh restart
sudo apt-get install apache2
andsudo apt-get install libapache2-mod-wsgi python-dev
- Enable mod_wsgi with
sudo a2enmod wsgi
- start the webserver
sudo service apache2 start
- First install git
sudo apt-get install git
- Navigate to www directory:
cd /var/www
- make catalog directory:
sudo mkdir catalog
- navigate to catalog
cd catalog
- clone the repo
git clone "github repo link" catalog
- run
nano catalog.wsgi
, Then write this inside 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 = 'secret key'
WTF_CSRF_ENABLED = True
.
- Then rename application.py (your main python file) to
__ini__.py
mv application.py __init__.py
- Flask
pip3 install Flask
- And the catalog project dependencies: ```sudo pip3 install httplib2 oauth2client sqlalchemy flask-sqlalchemy psycopg2-binary bleach requests sqlalchemy_utils``
- with
sudo nano /etc/apache2/sites-enabled/000-default.conf
- and change it with your server info
sudo apt-get install libpq-dev python-dev
sudo apt-get install postgresql postgresql-contrib
sudo su - postgres
- Then we create database for our project by:
psql
CREATE USER catalog WITH PASSWORD 'password';
ALTER USER udacity CREATEDB;
CREATE DATABASE catalog WITH OWNER udacity;
\c catalog
REVOKE ALL ON SCHEMA public FROM public;
GRANT ALL ON SCHEMA public TO catalog;
- we restart apache so the changes apply
sudo service apache2 restart
-Done.
This application has a build in web server that surves a web catalog for car makers and car models the user can authinticate via google account or github account and add,edit or delete their own data.
there is two JSON endpoints:
/model/<id>/JSON
: displays a single car model of id/carmaker/<id>/JSON
: displays all car models grouped by carmaker