YOURSERVERDOMAIN
sudo apt-get install apache2
sudo ufw allow 80/tcp
sudo ufw allow 443/tcp
sudo apt-get install software-properties-common
sudo add-apt-repository ppa:certbot/certbot
sudo apt-get update
sudo apt-get install certbot
sudo certbot certonly --standalone -d YOURSERVERDOMAIN -d YOURSERVERDOMAIN
sudo a2enmod ssl
sudo nano /etc/apache2/sites-enabled/000-default.conf
NameVirtualHost *:80
<VirtualHost *:80>
ServerName YOUR SERVER DOMAIN
DocumentRoot /usr/local/apache2/htdocs
Redirect permanent / https://YOURSERVERDOMAIN/
</VirtualHost>
<VirtualHost *:443>
ServerAdmin webmaster@localhost
DocumentRoot /var/www/html
ErrorLog ${APACHE_LOG_DIR}/error.log
CustomLog ${APACHE_LOG_DIR}/access.log combined
SSLEngine on
SSLCertificateFile /etc/letsencrypt/live/YOURSERVERDOMAIN/fullchain.pem
SSLCertificateKeyFile /etc/letsencrypt/live/YOURSERVERDOMAIN/privkey.pem
</VirtualHost>
sudo service apache2 restart