Ssl Xampp Localhost

Acronis true image 2020 standard license. There is an initiative, lead by Google and Mozilla, to deprecate HTTP and migrate all web traffic to HTTPS.

I am currently working towards migrating all of the sites I support to HTTPS, starting with my development environment, which is using Windows 10 and XAMMP.

I am using several virtual hosts for my projects. These are in the form: website1.local, website2.local, etc. The hosts file maps these back to the localhost (127.0.0.1).

Each of the virtual hosts are defined in xamppapacheconfextrahttpd-vhosts.conf as:

<VirtualHost *:80>
ServerName website1.local
DocumentRoot “C:Usersshiplhtdocswebsite1”
<Directory “C:Usersshiplhtdocswebsite1”>
Options Indexes FollowSymLinks Includes ExecCGI
AllowOverride All
Require all granted
</Directory>
</VirtualHost>

Create the certificates

Xampp Ssl Certificate Localhost

Xampp localhost not working

A very simple and easy test of a WordPress site is to try and load the “readme.html” file. Being able to view it validates that the webserver configuration has the correct directory mapped and that the files are readable. But how do I issue and install SSL Certificate on localhost? How can HTTPS work with localhost? In this short tutorial, we will try to do just that. Laragon will save our backs. With Laragon you can easily create localhost on a Windows machine. Those who are accustomed to using XAMPP or WAMP can easily find fun in Laragon. Localhost is a local web server for testing and development. In this tutorial, we learn to install XAMPP and setup localhost. What Will We Learn. Install XAMPP; Setup a local web server or localhost; Learn to view HTML file in localhost; What is XAMPP? XAMPP is a free and open source cross-platform web server. It is simple and easy to setup. Developing with http works ofcourse, but https is better, because thats common now. (Thank you Lets Crypt) Usually I am too lazy to start typing OpenSSL commands, so I made this to make life more easy. I use the certificates with xampp on Windows 10, but it will work with any XAMPP. Setting up an SSL certificate for XAMPP is pretty straight forward, but it won’t completely work if you are trying to use a private, local domain on your own computer. This is mostly caused by the certificates not being issues by a Certificate Authority, but rather it’s a self-signed certificate.

The first step is to create the self-signed certificates using the openssl package which is included as part of XAMPP in xamppapachebin (I am assuming this is in the PATH, otherwise use the fully qualified command path). I have installed XAMPP in C:Appsxampp – change this to suit your own configuration.

This is the script I used:

Xampp

set XAMPPDIR=C:Appsxampp
set HOME=%XAMPPDIR%apacheconf
set OPENSSL_CONF=%HOME%openssl.cnf
if not exist %HOME%ssl.crt mkdir %HOME%ssl.crt
if not exist %HOME%ssl.key mkdir %HOME%ssl.key
openssl req -subj “/C=AU/ST=Victoria/L=Port Melbourne/O=Paul Shipley/OU= /CN=localhost” -x509 -nodes -days 365 -newkey rsa:2048 -keyout %HOME%ssl.keylocalhost-selfsigned.key -out %HOME%ssl.crtlocalhost-selfsigned.crt
openssl req -subj “/C=AU/ST=Victoria/L=Port Melbourne/O=Paul Shipley/OU= /CN=website1.local” -x509 -nodes -days 365 -newkey rsa:2048 -keyout %HOME%ssl.keywebsite1-selfsigned.key -out %HOME%ssl.crtwebsite1-selfsigned.crt

Note that in the subj only the /CN=xxxxx part is actually required; the rest is just recorded in the certificate to be displayed if required.

Keep this script as these certificates will expire in 365 days, when you will need to create them again.

Configure Apache

Change the default SSL settings in xamppapacheconfextrahttpd-ssl.conf. Find these two parameters in the file and change them to use the self-signed certificate.

SSLCertificateFile “conf/ssl.crt/localhost-selfsigned.crt”

SSLCertificateKeyFile “conf/ssl.key/localhost-selfsigned.key”

Change each of the virtual host definitions to enable HTTPS. The default XAMPP host is:

<VirtualHost *:80>
ServerName localhost
Redirect / https://localhost/
</VirtualHost>
<VirtualHost *:443>
ServerName localhost
DocumentRoot “C:Appsxampphtdocs”
<Directory “C:Appsxampphtdocs”>
Options Indexes FollowSymLinks Includes ExecCGI
AllowOverride All
Require all granted
</Directory>
SSLEngine on
SSLCertificateFile “C:Appsxamppapacheconfssl.crtlocalhost-selfsigned.crt”
SSLCertificateKeyFile “C:Appsxamppapacheconfssl.keylocalhost-selfsigned.key”
</VirtualHost>

Xampp Localhost Not Working

Then my project sites are:

Localhost Xampp Htdocs Index Html

<VirtualHost *:80>
ServerName website1.local
Redirect / https://website1.local/
</VirtualHost>
<VirtualHost *:443>
ServerName website1.local
DocumentRoot “C:Usersshiplhtdocswebsite1”
<Directory “C:Usersshiplhtdocswebsite1”>
Options Indexes FollowSymLinks Includes ExecCGI
AllowOverride All
Require all granted
</Directory>
SSLEngine on
SSLCertificateFile “C:Appsxamppapacheconfssl.crtwebsite1-selfsigned.crt”
SSLCertificateKeyFile “C:Appsxamppapacheconfssl.keywebsite1-selfsigned.key”
</VirtualHost>

How To Use Xampp

Administrator

Once the new configuration has been saved, stop and start Apache (using the XAMPP Control Panel). The virtual hosts should now work with HTTPS and any references to HTTP will be redirected to HTTPS.