Configuring SSL certificate on XAMPP Apache Web Server

This is a record of how to set up SLL certificate of a domain name and website on XAMPP apache webserver for hosting website from home.

 Suppose you bought a new custom domain name or you have already one. For example in you can buy new domain at cheap price. The domain name may or not may have SSL certificate(https) and this is mandatory for web access to the site. Suppose that you don't have any SSL certificate for the domain name, then you either need to buy one or you can use free SSL certificate. There are couple of ways I think to generate and use SSL certificate for a domain. 

For example, you can buy positive SSL certificate for certain duration in namecheap. For 1 year it costed my around less than $6 for positive SSL certificate. This is my record of how I configured SSL certificate for one of my domain name in namecheap. I am hosting the website and domain name on my own XAMPP based apache server. See my previous post Hosting a website on an old computer with XAMPP which explains in details how you can host your website from home using static leased IP. 

The basic process of installing SSL certificate for a domain which is equivalently is same as activating https on your site are:

1) CSR code generation
2) SSL certificate activation
3) SSL certificate validation
4) SSL certificate installation

Now the steps from 1 to 3 are done in namecheap and the last 4th step is done on the computer running the XAMPP web server.

Buy SSL and Generate Keys

Now at namecheap, login and buy positive SSL for your domain name. Once you have purchased SSL certificate you have to activate it. From the dashboard(i think), you will see Activate button for the domain name. 

But before that you can activate it on the domain name of your interest, you first need to generate keys using the CSR (Certificate Signing Request) generator tool. These are required during the activation process. Namecheap provides such CSR generator tool and below is the link:

 Just fill up the form with domain name as the domain name for which you want to have SSL certificate. During the process you will provided with two keys which you should save. Next you will have to validate that the domain is yours. There are couple that will be provided and one of the CNAME record. If you choose DNS validation using CNAME record option for domain name verification and click on Get Record you will be provided with Host and Target value.

dns validation of ssl certificate

Now we have to create a new CNAME record and use the host and target value. In namecheap you can add new CNAME record by going the Advance DNS tab of your chosen domain name. There add the CNAME record for DNS validation.

CNAME DNS validation

At the end of the CSR generating process you will be mailed with the private key and a zipped file. The zipped contains two files your_domain.crt file and file. 

Open a text editor and copy paste the private key contain into the text editor. Save the file as your_domain.key file. Now you should have three files: your_domain.crt, and your_domain.key. Create a new folder for example in C:\XAMPP\Apache\ssl and copy the three files into the newly created ssl folder. We later need to specify the location of these files in the httpd-ssl.conf file in Apache server.

Installing an SSL certificate on XAMPP

 Once you have the 3 files( your_domain.crt, and your_domain.key), you can then start to install them in the XAMPP Apache web-server. We have to add virtual host record for port 80 and ssl record for port 433. For port 80 configuration, open the httpd-vhosts.conf file located in the directory C:\xampp\apache\conf\extra and add the following:

<VirtualHost *:80>   
    DocumentRoot "C:/xampp/htdocs/"

How to install XAMPP and how to configure to use virtual host in apache was explained in previous tutorial host website from home for free

Now for SSL certificate installation in windows XAMPP apache server, open the httpd-ssl.conf file also located in the C:\xampp\apache\conf\extra folder. Then add the following:

<VirtualHost *:443>   
    DocumentRoot "C:/xampp/htdocs/"
    SSLEngine on
    SSLCertificateFile "C:/xampp/apache/ssl/"
    SSLCertificateKeyFile "C:/xampp/apache/ssl/"
    SSLCertificateChainFile "C:/xampp/apache/ssl/"
Then you need to restart apache from the XAMPP control panel application. Now if everything worked perfectly then you should be able to reach your https website.

CNAME Record For WWW Redirect

 I think this is optional but we need to redirect the to For my case, I had to add a CNAME record with www as the host and as the value as shown below.

I created this record so that I don't forget how I configured it like most of my blog posts. I hope this is also useful for others. If you have any question or find any errors please leave it in the comment section below.

Post a Comment

Previous Post Next Post