Explore Technology Practical Guides Mac Smart Home Resume Projects Search the site
Tips

Quickly Enable SSL for Apache Web Server on Linux or Raspberry Pi: A Step-by-Step Guide

January 7, 2017 Freddy Reyes

Learn how to quickly enable SSL for Apache web server in Linux or Raspberry PI with this step-by-step guide. Create a directory, generate certificates, and configure SSL settings.

Quickly Enable SSL for Apache Web Server on Linux or Raspberry Pi: A Step-by-Step Guide

This post outlines how to swiftly enable SSL for an Apache web server on Linux or a Raspberry Pi.

  1. Begin by creating a directory to store the encryption certificates:
sudo mkdir /etc/apache2/ssl
  1. Generate the certificates, valid for 3 years (1095 days):
sudo openssl req -x509 -nodes -days 1095 -newkey rsa:2048 -out /etc/apache2/ssl/server.crt -keyout /etc/apache2/ssl/server.key

This command generates the following output:

Generating a 2048 bit RSA private key
...
writing new private key to '/etc/apache2/ssl/server.key'
...

Enter the required information when prompted.

  1. Install SSL for Apache:
sudo a2enmod ssl
  1. Edit the default Apache site (using sudo nano /etc/apache2/sites-enabled/000-default-ssl.conf) and add these lines:
SSLCertificateFile    /etc/apache2/ssl/server.crt
SSLCertificateKeyFile /etc/apache2/ssl/server.key
  1. Restart Apache:
sudo /etc/init.d/apache2 restart

And that's it!