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>
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 ☕. 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
Top comments (4)
Very helpfull,
Thanks
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
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?
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:
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.
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.
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.
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.
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.
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.