Enable SSL EVE PRO with Let’s Encrypt

HowTo enable SSL  EVE PRO with Let’s Encrypt

Don’t apply this method for EVE-COMMUNITY

NOTE: the procedure below require to keep open ports 80 and 443 to have periodic Let’s Encrypt certificate renewal

1 Setup your locales

Copy and paste :

export LC_ALL="en_US.UTF-8"
export LC_CTYPE="en_US.UTF-8"
sudo dpkg-reconfigure locales

Select ok twice and wait end of processing

2. Install certbot

On CLI, copy/paste following lines:

cd /usr/local/sbin
sudo wget https://dl.eff.org/certbot-auto
sudo chmod a+x /usr/local/sbin/certbot-auto

3. Stop Apache

systemctl stop apache2

4. Create Let’s encrypt certificate

You need to choose your full site name for this step. This sample will use www.example.com...

When script ask the file to use, choose 1) default-ssl.conf

certbot-auto certonly --standalone --preferred-challenges http -d www.exemple.com

5. Update apache config

CERT=$(find /etc/letsencrypt/live/ -name fullchain*)
KEY=$(find /etc/letsencrypt/live/ -name priv*)

sed -i --follow-symlinks /etc/apache2/sites-enabled/eveng-ssl.conf -Ee 's,(\s+SSLCertificateFile\s+).+,\1'$CERT',g'
sed -i --follow-symlinks /etc/apache2/sites-enabled/eveng-ssl.conf -Ee 's,(\s+SSLCertificateKeyFile\s+).+,\1'$KEY',g'

6. Restart apache

systemctl start apache2


Let’s Encrypt certificates are valid for 90 days, but it’s recommended that you renew the certificates every 60 days to allow a margin of error. The certbot-auto Let’s Encrypt client has a renew command that automatically checks the currently installed certificates and tries to renew them if they are less than 30 days away from the expiration date.

A practical way to ensure your certificates won’t get outdated is to create a cron job that will periodically execute the automatic renewal command for you. Since the renewal first checks for the expiration date and only executes the renewal if the certificate is less than 30 days away from expiration, it is safe to create a cron job that runs every week or even every day, for instance.

Let’s edit the crontab to create a new job that will run the renewal command every week. To edit the crontab for the root user, run:

crontab -e

Include the following content, all in one line:

30 2 * * 1 certbot-auto renew --pre-hook "systemctl stop apache2" --post-hook "systemctl start apache2" >> /var/log/le-renew.log