Xampp Cheat Sheet
- x
- Setting up HTTPS on XAMPP
- Generate a self-signed certificate for testing purposes
- Change htdocs location
- How to Setup a Virtual Host
-
SSL Configuration
- Configure
httpd-vhosts.conf
- Make SSL Keys - Configurehttpd.conf
x
Setting up HTTPS on XAMPP
- Navigate to the Apache directory in your XAMPP installation:
cd /c/xampp/apache
- Create a new directory to store your SSL keys with the
mkdir
command:
mkdir conf/ssl.crt
- Use the
openssl
command to generate a new self-signed SSL certificate:
openssl req -x509 -nodes -days 365 -newkey rsa:2048 -keyout conf/ssl.key/server.key -out conf/ssl.crt/server.crt
You will be prompted to enter some information for the certificate. Enter whatever you like, or leave the fields blank.
- Open the Apache
httpd.conf
configuration file in a text editor. You can find this file in the/xampp/apache/conf
directory. - Uncomment the line that includes the SSL module:
LoadModule ssl_module modules/mod_ssl.so
- Open the
httpd-ssl.conf
SSL configuration file in a text editor. You can find this file in the/xampp/apache/conf/extra
directory. - Find the lines that set the paths to the SSL certificate and key, and update them to point to the files you created earlier:
SSLCertificateFile "conf/ssl.crt/server.crt"
SSLCertificateKeyFile "conf/ssl.key/server.key"
Generate a self-signed certificate for testing purposes
**Requires OpenSSL ** which comes with git bash
Step 1: Generating a CSR and Private Key.
Step 2: Order and Configure the SSL Certificate.
Step 3: Download the SSL Certificate files and move them to the XAMPP.
Step 4: Add the site in Windows Hosts.
Step 5: Edit the SSL Configuration file for Apache.
# generate the private key
openssl genpkey -algorithm RSA -out private.key
Change htdocs location
- Go to
C:\xampp\apache\conf\httpd.conf
- Open
httpd.conf
- Find tag :
DocumentRoot "C:/xampp/htdocs"
- Edit tag to :
DocumentRoot "C:/xampp/htdocs/my/new/location"
- Now find tag and change it to
< Directory "C:/xampp/htdocs/my/new/location" >
- Restart Your Apache
How to Setup a Virtual Host
https://www.youtube.com/watch?v=H3uRXvwXz1o&index=2&list=PLillGF-RfqbYhQsN5WMXy6VsDMKGadrJ-
A virtual host allows a URL to be typed directly into the address bar when developing locally instead of using localhost
or 127.0.0.1
.
DO NOT use .dev because google does not like it!
Step 1. Edit C:\xampp\apache\conf\extra\vhost.conf
to create virtual host entry to point to the public folder in the Laravel project location.
<VirtualHost *:80>
DocumentRoot "C:\path\to\htdocs"
ServerName localhost
</VirtualHost>
<VirtualHost *:80>
DocumentRoot "C:\path\to\htdocs\SITEROOT\public"
ServerName mysite.test
</VirtualHost>
Step 2. Edit C:\Windows\System32\drivers\etc\hosts
MUST open in notepad as administrator
127.0.0.1 localhost
127.0.0.1 mysite.test
SSL Configuration
https://stackoverflow.com/questions/64800565/how-to-create-valid-ssl-in-localhost-for-xampp
httpd-vhosts.conf
Configure <VirtualHost *:443>
DocumentRoot "C:/xampp/htdocs"
ServerName site.test
ServerAlias *.site.test
SSLEngine on
SSLCertificateFile "crt/site.test/server.crt"
SSLCertificateKeyFile "crt/site.test/server.key"
</VirtualHost>
<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>
Make SSL Keys
httpd.conf
Configure # Virtual hosts
Include conf/extra/httpd-vhosts.conf