Install nginx
sudo apt update
sudo apt install nginx
To enable the service to start up at boot, you can type:
sudo systemctl enable nginx
Generate Diffie-Hellman keys:
sudo openssl dhparam -out /etc/nginx/dhparam.pem 2048
Generate selfsigned certs for default_server
:
sudo openssl req -x509 -nodes -days 365 -newkey rsa:2048 -keyout /etc/nginx/selfsigned-privkey.pem -out /etc/nginx/selfsigned-fullchain.pem
Copy all files from this repo to /etc/nginx/*
:
cd /etc/nginx/
sudo git clone https://github.com/fivemru/nginx-boilerplate.git
sudo cp -r ./nginx-boilerplate/* ./
sudo rm -fr nginx-boilerplate/ sites-enabled/default
Set up user in nginx.conf
(www-data or nginx).
Set up ./letsencrypt.conf
Set up ./sites-enabled/site.com.conf
Create the directory for site.com:
sudo mkdir -p /var/www/site.com/public
sudo chown -R $USER:$USER /var/www/site.com/public
sudo chmod -R 755 /var/www/site.com
echo "Hello world" > /var/www/site.com/public/index.html
Check config and start / restart / reload
sudo nginx -t && sudo systemctl start nginx
Reload (soft)
sudo nginx -t && sudo systemctl reload nginx
Restart (hard)
sudo nginx -t && sudo systemctl restart nginx