Enable ssl/https with apache2 on Ubuntu


First install apache2 on you Ubuntu machine then follow the procedure mentioned below to enable ssl/https.

Enable ssl:

$ sudo a2enmod ssl

Activate new virtual host:

$ sudo a2ensite default-ssl

Create 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

Above command will ask some details like country name, state, email address etc…

Set ssl certificates path in /etc/apache2/sites-available/default-ssl file:

$ vim /etc/apache2/sites-available/default-ssl

Find lines starting with SSLEngine, SSLCertificateFile, and SSLCertificateKeyFile change them as following:

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

then save and exit from default-ssl file.

Now reload apache2:

$ sudo service apache2 reload

After reloading try accessing your hostname/IP with https on your browser.


Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out /  Change )

Google+ photo

You are commenting using your Google+ account. Log Out /  Change )

Twitter picture

You are commenting using your Twitter account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )


Connecting to %s