Adding SSL to Ubuntu / Apache2

posted in: Linux | 0

First thing go here to to get the command to generate you SSL request. CSR    https://www.digicert.com/easy-csr/openssl.htm

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=*.testdomain.com”

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

/etc/apache2/sites-enabled/default-ssl.conf

———————Sample—————————————–

<IfModule mod_ssl.c>
<VirtualHost 192.168.1.55:443>
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
</FilesMatch>
<Directory /usr/lib/cgi-bin>
SSLOptions +StdEnvVars
</Directory>

</VirtualHost>
</IfModule>

# 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