Install Apache 2 with SSL On Debian based Linux | Drupal 8

Install Apache 2 with SSL On Debian based Linux

Submitted by editor on Sun, 10/30/2016 - 13:08

How to install apache2 with SSL on On Debian based Linux ?

Install Apache following this tutorial

Activate SSL Module

sudo a2enmod ssl
sudo service apache2 force-reload
#Or sudo /etc/init.d/apache2 force-reload

Create Certificate

Install SSL packages
sudo apt-get install ssl-cert

Create self signed certification (Or you can also use Let's Encrypt)
sudo make-ssl-cert /usr/share/ssl-cert/ssleay.cnf /etc/ssl/private/localhost.pem
sudo openssl req -x509 -nodes -days 365 -newkey rsa:1024 -out /etc/apache2/server.crt -keyout /etc/apache2/server.key
sudo chmod o-rw /etc/apache2/server.key


Configure Apache

Methode 1
cd /etc/apache2/sites-available/
sudo cp default-ssl ssl
sudo sed -i '1,2s/\*:80/*:443/' ssl
sudo sed -i "3a\\\tSSLEngine On\n\tSSLCertificateFile /etc/ssl/private/localhost.pem" ssl

Activate the ssl site
sudo a2ensite ssl


Methode 2

Edit  /etc/apache2/ports.conf and add
Listen 443

Edit your Host/VirtualHost file and add
    DocumentRoot /var/www/domainname

    SSLEngine on
    SSLCertificateFile /etc/apache2/server.crt
    SSLCertificateKeyFile /etc/apache2/server.key


Reload apache

sudo service apache2 reload
#Or sudo /etc/init.d/apache2 reload


Add new comment

This question is for testing whether or not you are a human visitor and to prevent automated spam submissions.
Enter the characters shown in the image.