This guide assumes a working Ubuntu 18.04 installation.
$ sudo apt update
$ sudo apt install nginx
$ sudo apt install python3-pip python3-dev build-essential libssl-dev libffi-dev python3-setuptools
$ sudo apt install python3-venv
$ conda activate random-phase-approximation
$ conda install gunicorn
$ cd ~/Development/random-phase-approximation/signac/projects/rpa/src
$ gunicorn --bind 0.0.0.0:5000 wsgi:dashboard
# /etc/systemd/system/rpa.service
[Unit]
Description=Gunicorn instance to serve random-phase-approximation/rpa
After=network.target
[Service]
User=berceanu
Group=www-data
WorkingDirectory=/home/berceanu/Development/random-phase-approximation/signac/projects/rpa/src
Environment="PATH=/home/berceanu/miniconda3/envs/random-phase-approximation/bin"
ExecStart=/home/berceanu/miniconda3/envs/random-phase-approximation/bin/gunicorn --workers 3 --bind unix:rpa.sock -m 007 wsgi:dashboard
[Install]
WantedBy=multi-user.target
$ sudo systemctl start rpa
$ sudo systemctl enable rpa
$ sudo systemctl status rpa
Notes:
- Add multiple services by changing the respective paths above and follow the same steps to enable them.
# /etc/nginx/sites-available/rpa
server {
listen 80;
listen [::]:80;
server_name rpa.ra5.ro www.rpa.ra5.ro;
location / {
include proxy_params;
proxy_pass http://unix:/home/berceanu/Development/random-phase-approximation/signac/projects/rpa/src/rpa.sock;
}
}
$ sudo ln -s /etc/nginx/sites-available/rpa /etc/nginx/sites-enabled
$ sudo nginx -t
$ sudo systemctl restart nginx
Notes
- Add more subdomains by changing the sock path above and making the respective symlinks.
- The subdomains need to have correct DNS A-record entries.
- The max socks path length is 107 chars.
$ sudo mkdir -p /var/www/ra5.ro/html
$ sudo chown -R $USER:$USER /var/www/ra5.ro/html
$ sudo chmod -R 755 /var/www/ra5.ro
$ vi /var/www/ra5.ro/html/index.html
<html>
<head>
<title>ra5.ro</title>
</head>
<body>
<h1><a href="http://rpa.ra5.ro">rpa</a></h1>
<h1><a href="http://rpa.agg.ra5.ro">rpa-aggregation</a></h1>
<h1><a href="http://rpa.agg.anim.ra5.ro">rpa-animation</a></h1>
</body>
</html>
$ sudo vi /etc/nginx/sites-available/ra5.ro
# /etc/nginx/sites-available/ra5.ro
server {
listen 80;
listen [::]:80;
root /var/www/ra5.ro/html;
index index.html index.htm index.nginx-debian.html;
server_name ra5.ro www.ra5.ro;
location / {
try_files $uri $uri/ =404;
}
}
$ sudo ln -s /etc/nginx/sites-available/ra5.ro /etc/nginx/sites-enabled/
$ sudo vi /etc/nginx/nginx.conf
# /etc/nginx/nginx.conf
...
http {
...
server_names_hash_bucket_size 64;
...
}
...
$ sudo nginx -t
$ sudo systemctl restart nginx
Adapted from this guide.
See also how to configure Nginx
(and links therein).