Adding SSL to Ubuntu / Apache2

posted in: Linux | 0

First thing go here to to get the command to generate you SSL request. CSR

Fill the information out and click Generate. Take the command and run it on your Ubuntu server

Sample Command: openssl req -new -newkey rsa:2048 -nodes -out star_testdomain_com.csr -keyout star_testdomain_com.key -subj “/C=US/ST=CA – California/L=Corona/O=JBS Housing/OU=Sales/CN=*”

Then take the file that is generate domain.csr and copy the content and  buy your certificate from a reputable provider.

Once you have your certificate copy both the certificate and the key file to /etc/apache2/ssl you may need to create that folder.  Also copy the Intermediate Certificate file to this folder.

Then run these commands

sudo a2enmod ssl

sudo a2ensite default-ssl
sudo chmod 644 /etc/apache2/ssl/*.crt
sudo chmod 640 /etc/apache2/ssl/private/*.key

Then edit this file



<IfModule mod_ssl.c>
ServerAdmin webmaster@localhost

DocumentRoot /var/www/html

ErrorLog ${APACHE_LOG_DIR}/error.log
CustomLog ${APACHE_LOG_DIR}/access.log combined

SSLEngine on

SSLCertificateFile /etc/apache2/ssl/mycert.crt
SSLCertificateKeyFile /etc/apache2/ssl/mycert.key
SSLCertificateChainFile /etc/apache2/ssl/intermediate.crt

<FilesMatch “\.(cgi|shtml|phtml|php)$”>
SSLOptions +StdEnvVars
<Directory /usr/lib/cgi-bin>
SSLOptions +StdEnvVars


# vim: syntax=apache ts=4 sw=4 sts=4 sr noet


Then run

sudo a2enmod ssl

Last restart Apache

sudo /etc/init.d/apache2 reload