#!/bin/bash
cd /var/www/domain.com && php -f /var/www/domain.com/camengine.php true
## Install CertBot
sudo apt-get install certbot
## Make www dir
sudo mkdir -p /var/www/cert_bot/.well-known/acme-challenge
sudo chown -R www-data:www-data /var/www/cert_bot
## Fix nging config
server {
listen 80;
server_name domain.com;
root /var/www/cert_bot;
location /.well-known/acme-challenge/ {
access_log off;
default_type "text/plain";
}
location / {
return 301 https://$server_name$request_uri;
}
}
## Request cert
sudo certbot certonly --webroot --agree-tos --email hostmaster@domain.com -w /var/www/cert_bot/ -d domain.com
## Add ssl to nging config
ssl_certificate /etc/letsencrypt/live/domain.com/fullchain.pem;
ssl_certificate_key /etc/letsencrypt/live/domain.com/privkey.pem;
## Add to cron for auto renew
0 0 10,25 * * certbot renew