Coder Social home page Coder Social logo

linux_server_configuration's Introduction

Linux Server configuration Project

About the project

A baseline installation of a Linux distribution on a virtual machine and prepare it to host web applications.

IP Address: 18.185.57.126

SSH Port: 2200

URL using DNS: 18.185.57.126

Steps Followed to Configure the server:

  1. Update all packages

sudo apt-get update

sudo apt-get upgrade

sudo apt-get dist-upgrade

  1. Enable automatic security updates

sudo apt-get install unattended-upgrades

sudo dpkg-reconfigure --priority=low unattended-upgrades

  1. Change timezone to UTC and Fix language issues

sudo timedatectl set-timezone UTC

sudo update-locale LANG=en_US.utf8 LANGUAGE=en_US.utf8 LC_ALL=en_US.utf8

  1. Create a new user grader and Give him sudo access

sudo adduser grader

sudo nano /etc/sudoers.d/grader

Then add the following text grader ALL=(ALL) ALL

  1. Setup SSH keys for grader On local machine ssh-keygen choose path for storing public and private keys copy the contents of the public key On remote machine home as user grader

sudo su - grader

mkdir .ssh

touch .ssh/authorized_keys

sudo chmod 700 .ssh

sudo chmod 600 .ssh/authorized_keys

nano .ssh/authorized_keys

Then paste the contents of the public key created on the local machine.

  1. Change the SSH port from 22 to 2200 | Enforce key-based authentication | Disable login for root user

sudo nano /etc/ssh/sshd_config

Then change the following: Find the Port line and edit it to 2200. Remove the '#' if it's put before the port line. Find the PasswordAuthentication line and edit it to no. Find the PermitRootLogin line and edit it to no. Save file run sudo service ssh restart

  1. Configure the Uncomplicated Firewall (UFW)

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

  1. Install Apache2 and mod-wsgi for python2 and Git

sudo apt-get install apache2 libapache2-mod-wsgi git

  1. Install and configure PostgreSQL

sudo apt-get install libpq-dev python-dev

sudo apt-get install postgresql postgresql-contrib

sudo su - postgres

psql

Then

CREATE USER catalog WITH PASSWORD 'password';

CREATE DATABASE catalog WITH OWNER catalog;

\c catalog

REVOKE ALL ON SCHEMA public FROM public;

GRANT ALL ON SCHEMA public TO catalog;

\q

exit

Note: In your catalog project you should change database engine to

engine = create_engine('postgresql://catalog:password@localhost/catalog')
  1. Connect with sftp to upload project zip file

sftp -P 2200 -i grader_private_key [email protected]

put item_catalog.zip

  1. from the grader user unzip the project file: if not downloaded download the unzip module.

sudo apt-get install unzip

unzip item_catalog.zip

  1. move project to catalog folder, unzip it and create configuration file:

cd /var/www/

sudo mkdir item_catalog

cd item_catalog

cd ~

mv item_catalog -r /item_catalog

nano catalog.wsgi

Then add the following in catalog.wsgi file

#!/usr/bin/python

import sys

sys.stdout = sys.stderr

Add this if you'll create a virtual environment, So you need to activate it

#-------
activate_this = '/var/www/item_catalog/env/bin/activate_this.py'
with open(activate_this) as file_:
    exec(file_.read(), dict(__file__=activate_this))
#-------

sys.path.insert(0,"/var/www/item_catalog")

from app import app as application

application.secret_key = 'secret_key'
  1. Setup virtual environment and Install app dependencies

sudo apt-get install python-pip

sudo -H pip install virtualenv

virtualenv env

source env/bin/activate

pip install flask packaging oauth2client redis passlib flask-httpauth

pip install sqlalchemy flask-sqlalchemy psycopg2 bleach requests

  1. Configure apache server

sudo nano /etc/apache2/sites-available/udacity-project.conf

Then add the following content:

serve catalog app

<VirtualHost *:80>
  ServerName 18.185.57.126
  ServerAdmin <Email>
  DocumentRoot /var/www/item_catalog
  WSGIDaemonProcess catalog user=grader group=grader
  WSGIScriptAlias / /var/www/item_catalog/catalog.wsgi
  <Directory /var/www/item_catalog>
    WSGIProcessGroup catalog
    WSGIApplicationGroup %{GLOBAL}
    Require all granted
  </Directory>
  ErrorLog ${APACHE_LOG_DIR}/error.log
  LogLevel warn
  CustomLog ${APACHE_LOG_DIR}/access.log combined
</VirtualHost>

Resources:

linux_server_configuration's People

Contributors

nadaelmasry avatar

Stargazers

 avatar

Watchers

 avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.