Press "Enter" to skip to content

How to create an SSL Certificate on Apache for Ubuntu VPS

An SSL certificate is a way to encrypt a site’s information and make a more secure connection. This is commonly used in merchant sites or just any other websites that want user data to be encrypted to prevent eavesdropping. On this tutorial I’ll show you how easy it is to install on your own Linux machine or VPS.

Activating the SSL module

sudo a2enmod ssl
sudo service apache2 restart

Create the SSL folder

sudo mkdir /etc/apache2/ssl

Create a Self-signed SSL Certificate

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

Enter your details on the prompt. Bold items need to be replaced with whatever relevant information.

Country Name (2 letter code) [AU]:PH
State or Province Name (full name) [Some-State]:Negros Occidental
Locality Name (eg, city) []:TC
Organization Name (eg, company) [Internet Widgits Pty Ltd]:Blgr
Organizational Unit Name (eg, section) []:Blogging Dept
Common Name (e.g. server FQDN or YOUR name) []
Email Address []:[email protected],info

Set up the SSL Certificate

Open up the SSL configuration file

sudo nano /etc/apache2/sites-available/default

Change the VirtualHost port into following (default is 80)

<virtualhost *:443>

Then add this line below (replace item in bold)

SSLEngine on
SSLCertificateFile /etc/apache2/ssl/apache.crt
SSLCertificateKeyFile /etc/apache2/ssl/apache.key

Activate and restart your Apache server

sudo a2ensite default
sudo service apache2 reload

Be First to Comment

Leave a Reply

Your email address will not be published. Required fields are marked *