Installing Packages on Server
- update OS and remove old packages
sudo apt update && apt dist-upgrade
- install virtualenv
sudo apt install python-virtualenv
- install libraries and dependencies for PostgreSQL
sudo apt install libpq-dev python-dev postgresql postgresql-contrib
- install NGINX
sudo apt install nginx
- install git and curl
sudo apt install git-all curl
- setup virtualenv and activate the venv
- install all the packages
pip install -r requirements.txt
- install gunicorn
pip install gunicorn
- login to PostgreSQL
sudo -u postgres -i
- create a database
createdb DB_NAME
- create a user
createuser -P USERNAME
- switch to the psql console
psql
- give the user all access to the database
GRANT ALL PRIVILEGES ON DATABASE db_name TO username;
- list all users
\du
- list all databases
\l
- quit psql console
\q
- give the user all access to the database
- quit postgres
crtl + d
- create a database
- setup git and clone your project from GitHub
- add DB name, user and password to settings.py of your project
Resources:
➡️https://www.digitalocean.com/community/tutorials/how-to-deploy-a-local-django-app-to-a-vps
➡️https://www.digitalocean.com/community/tutorials/initial-server-setup-with-debian-9