Setting up a Repo

Getting the server

Setup AWS i2c instance with Ubuntu LTS (right now it's 18.4)

Make sure to add a ssh key that you have access to

Wait for the sever to set and get the IP address

Now is a good time to redirect the a test URL to the new server.

Get into the server by using the key and username ubuntu

Setup your local computer for easy login, editing the ./ssh/config

Host <what you want to type into the terminal, usually edit, or nedic or cep...>
 HostName <ip address of the new server> 
 User ubuntu 
 IdentityFile ~/.ssh/<the .pem of the key> 
 IdentitiesOnly yes 
 ForwardAgent yes 


An example

Host designtennis
 HostName 35.183.41.218 
 User ubuntu 
 IdentityFile ~/.ssh/tennis.pem
 IdentitiesOnly yes 
 ForwardAgent yes 


Be sure to local have your ssh key you use for bit bucket being added to the terminal

ssh-add ~/.ssh/main_key 


Install on the server

You should now be able to ssh into the new server, if not try opening an new terminal window.

ssh <new host name>ssh designtennis


Setup the locals 

export LC_ALL="en_US.UTF-8" 
export LC_CTYPE="en_US.UTF-8" 
sudo dpkg-reconfigure locales 

Update the server and install the required elements.

sudo apt-get -y update && apt-get update 
sudo apt-get install -y zip python-certbot-apache python3 python3-pip python3-venv apache2 libapache2-mod-wsgi-py3 git mysql-client libmysqlclient-dev libjpeg-dev


Create the directory /srv/www/

Chown www

Make the directory for the new website

sudo mkdir /srv/www/desigtennis.comsudo chown ubuntu: -r /srv/www/designtennis.com

SSH clone the repo into /srv/www/designtennis.com


Get the REPO

Setup the python virtualenv

python3 -m venv envsource env/bin/activatepip install -r req.txt


Make the empty directory of 
logs

static

public_html

in the root of the directory e.g. mkdir /srv/ww/designtennis.com/logs

cp /srv/www/designtennis.com/application/application/wsgi.py /srv/www/designtennis.com/public_html/wsgi.py


If this site is going straight into launching change the settings to be DEBUG=False

vim /srv/www/designtennis.com/application/application/settings.py

and add the DEBUG=False in there


Set up Apache

chown www-data: -R /srv/www/designtennis.com 


sudo cp /srv/www/designtennis.com/unsecure.conf /etc/apache2/sites-available/designtennis.com.unsecure.conf


You might need to edit the designtennis.com.unsecure.conf to the local env

(the python might be the wrong version 3.5 to 3.6)

sudo a2ensite designtennis.com.unsecure.confsudo service apache2 restart



Updating a REPO

If you are pulling to update a server.

Dump data

git pull

pip uninstall page_cms

pip install libs page_cms

load data the dump't data

maybe -ignorenonexistent  if the data doens't load