HostOnNet Blog

Configuring SSL site in Ubuntu Server

Looking for Linux Server Admin or WordPress Expert? We can help.

Create file

vi /etc/apache2/sites-available/YOUR-DOMAIN.EXTN-ssl.conf

Add following content

<IfModule mod_ssl.c>
<VirtualHost _default_:443>
    ServerName YOUR-DOMAIN.EXTN
    ServerAlias www.YOUR-DOMAIN.EXTN
    ServerAdmin [email protected]
    DocumentRoot /home/YOUR-DOMAIN.EXTN/public_html/

    CustomLog ${APACHE_LOG_DIR}/YOUR-DOMAIN.EXTN-ssl.log combined
    ErrorLog ${APACHE_LOG_DIR}/error-YOUR-DOMAIN.EXTN-ssl.log
    
    SSLEngine on
    SSLCertificateFile  /etc/ssl/certs/YOUR-DOMAIN.EXTN.crt
    SSLCertificateKeyFile /etc/ssl/private/YOUR-DOMAIN.EXTN.key
    SSLCACertificateFile /etc/apache2/ssl.crt/YOUR-DOMAIN.EXTN.ca-bundle

    <Directory "/home/YOUR-DOMAIN.EXTN/public_html/">
        Options All
        AllowOverride All
        Require all granted
        Order allow,deny
        allow from all
    </Directory>

</VirtualHost>
</IfModule>

Enable the web site

a2ensite YOUR-DOMAIN.EXTN-ssl

Enable Apache SSL module if not already enabled

a2enmod ssl

Restart Apache

service apache2 restart

You can verify SSL module enabled by running

[email protected]:~# apachectl -M | grep ssl
 ssl_module (shared)
[email protected]:~# 

Now web site will work with SSL certificate.

Posted in Apache

Leave a Reply

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

This site uses Akismet to reduce spam. Learn how your comment data is processed.