You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Get an ubuntu VM, setup authorization, create a new user and add it to sudoers.
adduser emre
usermod -aG sudo emre
Update the machine via sudo apt update && sudo apt upgrade -y
Install python and virtualenv if not available.
Install and setup postgresql:
sudo apt install postgresql postgres-contrib -y
Disable peer authentiacation to access it from other users:
su - postgres
psql -U postgres
\password postgres
\q
cd /etc/postgresql/12/main
sudo vi postgresql.conf # here change listen_addresses = ['*']. This is not best practise. Consider limiting access to certain IP addresses/domains.
sudo vi pg_hba.conf
# here change the line [local all postgres peer] to [local all postgres md5]# change the line [host all all 127.0.0.1/32 md5] to [host all all 0.0.0.0/0 md5] --> meaning any IP address# change the line [host all all ::1/128 md5] to [host all all ::/0 md5]
systemctl restart postgres # restart postgres app
Setup project folder:
mkdir app_name
cd app_name
virtualenv venv
source venv/bin/activate
mkdir src
cd src
git clone <git_repo.git>.# put dot to prevent new folder with the repo name
pip install -r requirements.txt # if you get any errors, look for line with #include <libname.h>, then sudo apt install it, and retry
Setup environment variables:
cd~
touch .env
vi .env # then copy paste .env file content from local to VM
vi .profile # add this line to the end of file (enable env vars at reboot): set -o allexport; source /home/emre/.env; set +o allexport
Update alembic tables:
cd~/app_name/src/
alembic upgrade head
Setup Gunicorn for automated app running on machine reboot:
pip install gunicorn httptools uvloop
# setup service for autostart of api on rebootcd /etc/systemd/system
sudo vi api.service # copy content of ~/app_name/src/gunicorn.service file and modify as needed
sudo systemctl enable api # this enables starting of service on reboot
systemctl restart api
systemctl status api # should look active