Setting up a linux server to host our web application,secure it from various attacks complete description of how to setup,configure and deploy our server
- Item-catalog
- public ip address :- 13.126.69.17
- click here to setup a development enviroment.
- create a instance and then you will get a public ip address.
- Download the private key.
- Move the private key in a folder on your machine
- change the access of the private key so only owner can access .
$ chmod 600 ~/.ssh/key
- ssh into the instance .
$ ssh -i ~/.ssh/key.rsa root@public_IP_address
- command to add user.
sudo adduser grader
- try to run .
sudo/etc/var
- it shows the error because grader has no access to sudo .
- To give grader access to sudo .
$ sudo nano /etc/sudoers.d/grader
- add the text to the craeted file
grader ALL=(ALL:ALL) ALL
- Now again run the command
sudo/etc/var
- now the above command will work because now grader have access to sudo
- login as user
- touch .ssh/authorized_keys
- chmod 700 .ssh
$ 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 apt-get install unattended-upgrades
$ sudo dpkg-reconfigure --priority=low unattended-upgrades
$ sudo apt-get install apache2 libapache2-mod-wsgi git
$ sudo a2enmod wsgi
$ sudo apt-get install libpq-dev python-dev
$ sudo apt-get install postgresql postgresql-contrib
$ sudo su - postgres
$ psql
* Create user kunal with password 'xyz'
* Create database food with owner kunal
* \c catalog
* REVOKE ALL ON SCHEMA public FROM public;
* GRANT ALL ON SCHEMA public TO catalog
* \q
engine = create_engine('postgresql://kunal:yourPassword@localhost/food')
$ sudo apt-get install python-pip
$ sudo pip install Flask
$ sudo pip install httplib2 oauth2client sqlalchemy psycopg2 sqlalchemy_utils
$ sudo pip install requests
* clone the repository from [here](https://github.com/kunal121/Item-catalog)
* switch to the branch deployment by command git checkout deployment
$ touch bookCatalog.wsgi && nano bookCatalog.wsgi
import sys
import logging
logging.basicConfig(stream=sys.stderr)
sys.path.insert(0, "/var/www/Item-catalog/")
from project import app as application
$ python database_setup.py
$ python dummybooks.py
<VirtualHost *:80>
ServerName XX.XX.XX.XX
ServerAdmin kunalkalra121@gmail.com
WSGIScriptAlias / /var/www/Item-catalog/Item-catalog.wsgi
<Directory /var/www/Item-catalog/>
Order allow,deny
Allow from all
</Directory>
Alias /static /var/www/Item-catalog/static
<Directory /var/www/Item-catalog/static/>
Order allow,deny
Allow from all
</Directory>
</VirtualHost>
$ sudo service apache2 restart