Skip to content

Instantly share code, notes, and snippets.

@Arcyfa
Last active April 15, 2018 07:43
Show Gist options
  • Save Arcyfa/c197b17a81f7a2a5ee1e7842db259de7 to your computer and use it in GitHub Desktop.
Save Arcyfa/c197b17a81f7a2a5ee1e7842db259de7 to your computer and use it in GitHub Desktop.
XAMPP on windows 10 with vhosts and https
[HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Windows\CurrentVersion\Policies\System]
"ConsentPromptBehaviorAdmin"=dword:00000000
"EnableLUA"=dword:00000000
"PromptOnSecureDesktop"=dword:00000000
# Copyright (c) 1993-2009 Microsoft Corp.
#
# This is a sample HOSTS file used by Microsoft TCP/IP for Windows.
#
# This file contains the mappings of IP addresses to host names. Each
# entry should be kept on an individual line. The IP address should
# be placed in the first column followed by the corresponding host name.
# The IP address and the host name should be separated by at least one
# space.
#
# Additionally, comments (such as these) may be inserted on individual
# lines or following the machine name denoted by a '#' symbol.
#
# For example:
#
# 102.54.94.97 rhino.acme.com # source server
# 38.25.63.10 x.acme.com # x client host
# localhost name resolution is handled within DNS itself.
# 127.0.0.1 localhost
# ::1 localhost
127.0.0.1 vhost.local
<?php
echo "We are using the port: " . $_SERVER['SERVER_PORT'];
?>
update mysql.user table
mysql -u root -p
use mysql;
alter table mysql.user drop column default_role;
alter table mysql.user drop column max_statement_time;
alter table mysql.user drop column password_expired;
quit
[HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Windows\CurrentVersion\Policies\System]
"ConsentPromptBehaviorAdmin"=dword:00000005
"EnableLUA"=dword:00000001
"PromptOnSecureDesktop"=dword:00000000
# http
<VirtualHost vhost.local:80>
DocumentRoot "C:/xampp/htdocs/vhost.local"
DirectoryIndex index.php
<Directory "C:/xampp/htdocs/vhost.local">
Options All
AllowOverride All
Require all granted
</Directory>
</VirtualHost>
# https
<VirtualHost vhost.local:443>
DocumentRoot "C:/xampp/htdocs/vhost.local"
ServerName vhost.local
SSLEngine on
SSLCertificateFile "conf/ssl/vhost.local_ssl/ssl.crt/server.crt"
SSLCertificateKeyFile "conf/ssl/vhost.local_ssl/ssl.key/server.key"
<Directory "C:/xampp/htdocs/vhost.local">
Options All
AllowOverride All
Require all granted
</Directory>
</VirtualHost>

A attempt to install xampp and enable https on vhosts

Step 1 - Disable UAC Save disable_UAC.reg and restore_UAC.reg double click disable_UAC.reg Follow all step that will pop up and do reboot the machine.

Step 2 -Install XAMPP Download the XAMPP installer and install XAMPP.

Step 3 - Restore UAC Save restore_UAC.reg if you did not do so in step one Double click restore_UAC.reg Follow all step that will pop up and do reboot the machine.

Step 4 - Configure apache's vhosts for ssl/https We are gonna creat a named vhost as it looks prettier then 127.0.0.1 or 192.169.0.231. For this example we are naming it vhost.local but pick something you fancy. Do not pick a existing domain name that you want to still want use like google.com as.

Step 4.1 - Add vhost.local to hosts file Open "Search windows" and type notepad, click on it with right mouse button and choose "Run as Administrator" Goto "File" > "Open" and open the following file "C:\Windows\System32\drivers\etc\hosts" At the bottom add a new line with the following "127.0.0.1 vhost.local" do not include the " symbols Save and exit. See exmple of hosts file.

Step 4.2 - Generating a certificate for vhost.local In "C:\xampp\apache\conf" create a new folder called "ssl" In this folder "C:\xampp\apache\conf\ssl" create a folder "localhost_ssl" and "vhost.local_ssl" Copy the following three folders "C:\xampp\apache\conf\ssl.crt", "C:\xampp\apache\conf\ssl.csr" and "C:\xampp\apache\conf\ssl.key" to "C:\xampp\apache\conf\ssl\localhost_ssl" In "C:\xampp\apache" there is a batch file to create a new certificate locate "makecert.bat" and then double click. The batch script is going to ask some things that do not matter just make up A password but remember it and fill out the next few questions till it askes "Common Name (e.g. server FQDN or YOUR name) []:" Here we can give the name of the domain this certificate is for in this axample vhosts.local Common Name (e.g. server FQDN or YOUR name) []:vhost.local Awnser the rest of the questions untill you reach "Enter pass phrase for privkey.pem:" now fill in the password given in the begining of the script. The script will create new certificates and move them to "C:\xampp\apache\conf\ssl.crt" and "C:\xampp\apache\conf\ssl.csr" folders. Now go to "C:\xampp\apache\conf" and copy folders "ssl.crt", "ssl.csr" and "ssl.key" to "C:\xampp\apache\conf\ssl\vhost.local_ssl" Last step is to restore XAMPP's certificates for localhost by going to "C:\xampp\apache\conf\ssl\localhost_ssl" and copy folders "ssl.crt", "ssl.csr" and "ssl.key" back to "C:\xampp\apache\conf"

Step 4.3 - Add a vhost to apache Open "C:\xampp\apache\conf\extra\httpd-vhosts.conf" and add the example of "vhost.conf" file to the bottom. lets create a folder for this vhist as well. Go to "C:\xampp\htdocs" and create a folder "vhost.local" Add the file "index.php".

Step 4.4 - Update httpd-ssl.conf Open "C:\xampp\apache\conf\extra\httpd-ssl.conf" Find "ServerName" and replace ww.example.com with localhost

Step 4.5 - restart apache Open XAMPP control panel and restart appache

NOTE: Google Chrome, Firefox and any other browser will not accept this as Secure https!

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