Skip to content

Instantly share code, notes, and snippets.

@iahtisham
Last active August 11, 2023 12:02
Show Gist options
  • Save iahtisham/09650933ea013fdc14906f56b191e180 to your computer and use it in GitHub Desktop.
Save iahtisham/09650933ea013fdc14906f56b191e180 to your computer and use it in GitHub Desktop.
How to enable HTTPS For 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.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment