Step 2. Install SSL using Let’s Encrypt

Setting up Apache to use ServerName:

First of all let’s configure apache to include ServerName. Open the apache configuration file for the default site in “/etc/apache2/sites-enabled/000-default.conf”. Uncomment the “ServerName” parameter and change it with the domain you want to use for your private repository. Ex: “packagist.domain.com”.

The file should look like this:

1

2

3

4

5

6

7

8

9

<VirtualHost *:80>

ServerName packagist.domain.com

ServerAdminwebmaster@localhost

DocumentRoot/var/www/html

ErrorLog${APACHE_LOG_DIR}/error.log

CustomLog${APACHE_LOG_DIR}/access.log combined

</VirtualHost>

Restart apache typing this command in your console:

1

sudo service apache2 restart

Installing Let’s Encrypt Client:

Let’s Encrypt client require a non-root sudo enabled-user. If you already have one you can skip adding these commands:

1

2

adduser letsencrypt

usermod-aG sudo letsencrypt

Log into your server using using the your sudo-enabled account. Let’s go ahead and install the official Let’s Encrypt client called Certbot.

1

2

3

sudo add-apt-repository ppa:certbot/certbot

sudo apt-get update

sudo apt-get install python-certbot-apache

Set up the SSL Certificate:

To obtain a certificate, run the
certbot command like so, where “packagist.domain.com” is your domain:

1

sudo certbot--apache-dpackagist.domain.com

Follow the installation process and you should get the following message if everything is good: