How to enable HTTPS on XAMPP server.
Tags: xampp, https, ssl, beginners
Published: 2023-08-11 12:12:56

###You can checkout this article along with more programming related tips and articles on my personal website:

####https://www.iahtisham.com/blog/how-to-enable-https-on-xampp-server




Following are Steps to setup HTTPS for XAMP;

## STEP 1 Installing XAMMP
  Download and install XAMPP [Here](https://www.apachefriends.org/download.html)
  
## STEP 2 Adding VirtualHost
  Navigate to 
   `C:\xampp\apache\conf\extra`
  
  Open **httpd-vhosts-conf** file in Notepad
  
  add a **VIRTUALHOST** in the end by copying following code
  
  ```
  # Virtual Hosts
<VirtualHost *:443>
    DocumentRoot "C:/xampp/htdocs/"
    ServerName localhost
    SSLEngine on
    SSLCertificateFile "conf/ssl.crt/server.crt" 
    SSLCertificateKeyFile "conf/ssl.key/server.key"
    <Directory "C:/xampp/htdocs/">
        Options All
        AllowOverride All
        Require all granted
    </Directory>
</VirtualHost>
  ```
  **ServerName** will be the URL you want to setup HTTPS on; In this case We are using **localhost** 
  
## STEP 3 Creating Private Key
  Now We will create **Private KEY**. Navigate to the directory **C:\xampp\apache**.
  
  Open `makecert.bat`. It will ask Pass Phrase and some questions. You can give answers of your choices but **the comman name should be   the URL for which you are setting up SSL for; in this case its "localhost"**.
  
  Once done with it you can find the certificates and Key folder in the following directory
  
  ``C:\xampp\apache\conf``
 
## STEP 4 Configure httpd.config
 
 Now, Navigate to ``C:\xampp\apache\conf``. We will be configuring our `httpd.config` file,
 
 All we need to do is to include following lines in the very bottm of ``httpd.config`` file.
 
 ```
 # Virtual hosts
Include conf/extra/httpd-vhosts.conf
```
## STEP 4 Installing Certificate

Now, Open `ssl.crt` folder and Install the certificate on the local machine by follwing steps;]
- open `server.crt`
- click **install certificate""
* click **local machine**, then proceed next
* click on **Place all certificates in the following store"
  * Browse and Choose **Trusted Root Certification Authorities**, click **OK** and **NEXT**
* Click **Finish**

**A message will pop up saying** _**""the import was successfull""**_
 
## STEP 5 Configure Chrome
  We will enable **Allow invalid certificates for resources loaded from localhost.** in Chrome.

  for this paste the following on URL, it will lead you directly to it.
  
  ``chrome://flags/#allow-insecure-localhost``
  
  Restart your XAMPP services and restart chrome as well.
  
  **You should now be able to access your website with HTTPS / SSL enabled.**



##Support Me!!
If you found this post helpful, consider [buying me Coffee ☕](https://www.buymeacoffee.com/iahtisham). Your support keeps me fueled to create more content!


Public Gist URL: [https://gist.github.com/iahtisham/09650933ea013fdc14906f56b191e180](https://gist.github.com/iahtisham/09650933ea013fdc14906f56b191e180)

###Honorable Mentions:
Transform your daily grind with this dynamic calculator website – your ultimate solution for real-world problems! Explore now for a seamless and efficient experience!. Here are some of my favorites
 
1. [Markup Calculator](https://www.margincalculator.net/calculators/markup-calculator/)
 
2. [APY Calculator]
(https://www.margincalculator.net/calculators/apy-calculator/)