Skip to content

Instantly share code, notes, and snippets.

@bay007
Created January 3, 2020 16:42
Show Gist options
  • Save bay007/f409b264f033f8ebd3d2f6ffa1bdda90 to your computer and use it in GitHub Desktop.
Save bay007/f409b264f033f8ebd3d2f6ffa1bdda90 to your computer and use it in GitHub Desktop.
sudo apt update &sudo apt upgrade
sudo apt install postgresql postgresql-contrib
sudo -i -u postgres
psql -h localhost
# \du
# create database alphadb01
# \l
# create user restricteduser01 with encrypted password 'ER#df6512**!ff#sd...';
# GRANT CONNECT ON DATABASE alphadb01 TO restricteduser01;
# GRANT SELECT, INSERT, UPDATE, DELETE ON ALL TABLES IN SCHEMA public TO restricteduser01;
# ALTER ROLE "restricteduser01" WITH LOGIN;
# ALTER USER restricteduser01 WITH NOSUPERUSER;
# \q
psql -h localhost -U restricteduser01 -d alphadb01
nano /etc/postgresql/10/main/pg_hba.conf
sudo service postgresql restart
sudo /etc/init.d/postgresql restart
psql -h localhost -U restricteduser01 -d alphadb01
sudo apt install nginx
systemctl status nginx
sudo nano /etc/nginx/sites-enabled/default
sudo pip3 install gunicorn
sudo pip3 install django==2.2.2
/usr/local/bin/gunicorn --workers 1 --bind 127.0.0.1:8000 alphabed.wsgi:application
sudo nano /etc/systemd/system/gunicorn.service
[Unit]
Description=gunicorn daemon
After=network.target
[Service]
User=your_user_here
Group=your_user_here
WorkingDirectory=/home/produccion/alphabed
ExecStart=/usr/local/bin/gunicorn --workers 2 --bind 127.0.0.1:8000 alphabed.wsgi:application
[Install]
WantedBy=multi-user.target
sudo systemctl start gunicorn
sudo systemctl enable gunicorn
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment