DEV Community

Ahtisham Hasan Khan
Ahtisham Hasan Khan

Posted on • Edited on

How to enable HTTPS on XAMPP server.

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

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>
Enter fullscreen mode Exit fullscreen mode

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
Enter fullscreen mode Exit fullscreen mode

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 ☕. Your support keeps me fueled to create more content!

Public Gist URL: 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

  2. APY Calculator

Top comments (5)

Collapse
 
shabeehhaider profile image
Shabeeh

Very helpfull,
Thanks

Collapse
 
hmazuji profile image
hamid mazuji

when you say "Restart your XAMPP services and restart chrome as well", and it's late, and i'm not paying attention, and it's been a while since i've look't xampp, it was kinda tough. you need to explicity say "stop apache" "stop mysql", then restart xampp. after pasting code, you might want to explicitly say "save". also, you might want to search through your httpd.config file because you might already have that code for virtual hosts. finally, thanks for the walkthrough, although https still didn't work. i'm going to look for a new version of xampp. might have something to do with:
Issued On Tuesday, November 10, 2009 at 6:48:47 PM
Expires On Friday, November 8, 2019 at 6:48:47 PM

Collapse
 
iahtisham profile image
Ahtisham Hasan Khan

Thanks a lot for the feedback! I really appreciate you taking the time to go through the article. I aimed to keep things concise rather than breaking down each individual service. It sounds like the expired SSL certificate might be the issue, so updating or regenerating it should hopefully fix the HTTPS problem. If you run into any more trouble, feel free to reach out, and I’ll be happy to help.

Good luck with finding a new version of XAMPP, and thanks again for the suggestions!

Cheers,
Ahtisham

Collapse
 
eliargon profile image
Eli Argon • Edited

I followed all your steps to the letter and my XAMP refuse to start- message is red!
Problem detected!
Port 80 in use by "Unable to get info" with PID 13596!
Apache WILL NOT start without the configured ports free!
You need to uninstall/disable/reconfigure the blocking application
or reconfigure Apache and the Control Panel to listen on a different port

tried: uncomment "Include conf/extra/httpd-ssl.conf" in httpd.conf
tried: removed all other vhost.conf files
no luck
only when I commented the "Include conf/extra/httpd-vhosts.conf"
it worked again.
any ideas why?

Collapse
 
iahtisham profile image
Ahtisham Hasan Khan • Edited

It seems like there might be a conflict with the configuration in your httpd-vhosts.conf file that's causing Apache to fail to start. Here are some possible reasons and solutions:

  1. Port 80 Conflict: The error message indicates that port 80 is in use by another application or service with PID 13596. This can prevent Apache from starting because it also needs to use port 80 by default. You can try to identify the application or service using port 80 and stop it, or you can configure Apache to use a different port.

  2. Configuration Error: There might be a syntax error or conflicting configuration in your httpd-vhosts.conf file. Double-check the VirtualHost configuration you added in Step 2 to ensure it's correctly formatted and doesn't conflict with other configurations.

  3. SSL Certificate Configuration: Make sure the paths to your SSL certificate files (server.crt and server.key) in the VirtualHost configuration are correct and accessible by Apache.

  4. Other Configuration Files: Ensure that there are no conflicting configurations in other Apache configuration files (httpd.conf, httpd-ssl.conf, etc.). Uncommenting Include conf/extra/httpd-ssl.conf in httpd.conf is a good step, but make sure there are no conflicting settings.

  5. Check for Other VirtualHost Configurations: If you have multiple VirtualHost configurations in different files, ensure they don't conflict with each other. You mentioned removing other vhost.conf files, but make sure there are no other VirtualHost configurations interfering.

  6. Restart XAMPP: After making any changes to the configuration files, restart XAMPP to apply the changes and attempt to start Apache again.

By carefully reviewing and troubleshooting the configuration files, you should be able to identify and resolve the issue causing Apache to fail to start. If you continue to experience issues, double-check each step of the HTTPS setup process to ensure everything is configured correctly.