Giter VIP home page Giter VIP logo

asaeles-web-server's Introduction

Amazon Lightsail Ubuntu Web Server Setup

Details for setting up the Catalog Flask App on a newly created Amazon Lightsail Ubuntu VM

The server is currently setup on http://100.26.1.198/

Server Security

  1. Update packages
    sudo apt-get update
    sudo apt-get upgrade
    sudo apt-get dist-upgrade
  1. Increase automatic updates by uncommenting the below line from /etc/apt/apt.conf.d/50unattended-upgrades
    "${distro_id}:${distro_codename}-updates";

And update the /etc/apt/apt.conf.d/20auto-upgrades file to be as follows

    APT::Periodic::Update-Package-Lists "1";
    APT::Periodic::Download-Upgradeable-Packages "1";
    APT::Periodic::AutocleanInterval "7";
    APT::Periodic::Unattended-Upgrade "1";
  1. Check status of ufw to make sure messing up the ports won't brick the server
    sudo ufw status
  1. Edit Amazon firewall settings to add new ports SSH TCP 2200 and NTP UDP 123 from the below URL https://lightsail.aws.amazon.com/ls/webapp/us-east-1/instances/asaeles-web-server/networking

  2. Edit SSH config to make sure password login is disabled and to change port to 2200 and set PermitRootLogin to no

    sudo nano /etc/ssh/sshd_config
  1. Restart SSH service
    sudo service ssh restart
  1. Test SSH on the new port and make sure it is working

  2. Setup ufw

    sudo ufw default deny incoming
    sudo ufw defualt allow outgoing
    sudo ufw allow www
    sudo ufw allow ntp/tcp
    sudo ufw allow 2200/tcp
  1. Enable ufw
    sudo ufw enable
    sudo ufw status

Create User

  1. Add new user grader
    sudo adduser grader
  1. Create new key pair using PuTTY Key Gen for Windows then copy the public key and save the private key to "grader.ppk"
  2. Add public key to authorized keys copy/paste
    su grader
    cd ~
    mkdir .ssh
    nano .ssh/authorized_keys
    chmod 700 .ssh
    chmod 644 .ssh/authorized_keys
  1. Add new user to sudoers by copying any existing file
    sudo cp /etc/sudoers.d/90-cloud-init-users /etc/sudoers.d/grader
    sudo nano /etc/sudoers.d/grader
  1. Test login and sudo using user grader

Web Server Setup

  1. Install Apache and PostgresSQL
    sudo apt-get install apache2
    sudo apt-get install libapache2-mod-wsgi
    sudo apt-get install postgresql
    sudo apt-get install libpq-dev
    sudo apt install redis-server
    nohup redis-server &
  1. Install Flask and SQL Alchemy
    sudo apt-get install python-pip
    pip install --upgrade pip
    sudo su
    pip install flask
    pip install flask_httpauth
    pip install requests
    pip install sqlalchemy
    pip install psycopg2
    pip install redis
    exit
  1. Configure catalog app using catalog.conf and catalog.wsgi
    sudo rm /etc/apache2/sites-enabled/000-default.conf
    sudo nano /etc/apache2/sites-available/catalog.conf
    sudo ln -s /etc/apache2/sites-available/catalog.conf /etc/apache2/sites-enabled/catalog.conf
    sudo mkdir /var/www/catalog/
    sudo nano /var/www/catalog/catalog.wsgi
    sudo apache2ctl restart

Setup Catalog App

  1. Setup DB
    sudo -u postgres psql

Then run the following PSQL commands replacing 'password'

    CREATE USER catalog NOCREATEDB NOCREATEUSER PASSWORD 'password';
    CREATE DATABASE catalog OWNER catalog;
  1. Setup catalog app as per the readme file for repository
    cd /var/www/catalog
    sudo git clone https://github.com/asaeles/catalog.git
    cd catalog
    sudo cp catalog_default.ini catalog.ini
    sudo nano catalog.ini
    sudo nano templates/index.html

asaeles-web-server's People

Contributors

asaeles 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.