fbpx

How To Create a SSL Certificate on Apache for Ubuntu 14.04

How To Create a SSL Certificate on Apache for Ubuntu 14.04

TLS, or transport layer security, and its predecessor SSL, secure sockets layer, are secure protocols created in order to place normal traffic in a protected, encrypted wrapper.
In this guide, i will cover how to create a self-signed SSL certificate for Apache on an Ubuntu 14.04 server, which will allow you to encrypt traffic to your server.
We have to enable SSL

sudo a2enmod ssl

After you have enabled SSL, you’ll have to restart the web server for the change to be recognized

sudo service apache2 restart

We will make a directory in which ssl will be stored

sudo mkdir /etc/apache2/ssl

This is the most important command which will create ssl certificate for you.

sudo openssl req -x509 -nodes -days 365 -newkey rsa:2048 -keyout /etc/apache2/ssl/apache.key -out /etc/apache2/ssl/apache.crt

When you hit “ENTER”, you will be asked a number of questions
The most important item that is requested is the line that reads “Common Name (e.g. server FQDN or YOUR name)”
Create a virtual host file of the ssl in which configurtion will be placed for ssl

sudo nano /etc/apache2/sites-available/your-site-name-ssl.conf

Place the code website and replace the domain-name which you are setting it up for.

<IfModule mod_ssl.c>
 <VirtualHost _default_:443>
  ServerName your-domain-name.com
  ServerAlias www.your-domain-name.com
  DocumentRoot /var/www/your-domain-name.com
  <Directory "/var/www/your-domain-name.com">
   allow from all
   AllowOverride all
   Options +Indexes
  </Directory>
  ErrorLog ${APACHE_LOG_DIR}/error.log
  CustomLog ${APACHE_LOG_DIR}/access.log combined
  SSLEngine on
  SSLCertificateFile /etc/apache2/ssl/apache.crt
  SSLCertificateKeyFile /etc/apache2/ssl/apache.key
 </VirtualHost>
</IfModule>

Now that we have configured our SSL-enabled virtual host, we need to enable it.

sudo a2ensite your-site-name-ssl.conf

We then need to restart Apache to load our new virtual host file

sudo service apache2 restart

Test your website with https protocal
https://your-domain-name.com
 

Share this post