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
<VirtualHost 192.168.0.2:443>
ServerName domainname.com
DocumentRoot /var/www/domainname
SSLEngine on
SSLCertificateFile /etc/apache2/server.crt
SSLCertificateKeyFile /etc/apache2/server.key
</VirtualHost>
Reload apache
sudo service apache2 reload
#Or sudo /etc/init.d/apache2 reload
Comments