-
Notifications
You must be signed in to change notification settings - Fork 10
XAMPP: Windows
I needed a simple way to test some demo pages, so I installed XAMPP:
The following assumes that XAMPP is installed in the following directory: C:\Program Files\
_Also \
is replaced with /
for Markdown purposes
Once you've installed XAMPP, navigate to and open:
C:/Program Files/xampp/apache/conf
... and un-comment the vhosts
line (if it isn't already un-commented), so that it looks like this:
# Virtual hosts
Include "conf/extra/httpd-vhosts.conf"
Next, navigate to and open:
C:/Program Files/xampp/apache/conf/extra/httpd-vhosts.conf
Now, comment-out (if it isn't already commented-out) the existing virtual host containers and add:
# this keeps http://localhost working
<VirtualHost *:80>
DocumentRoot "C:/Program Files/xampp/htdocs"
ServerName localhost
</VirtualHost>
<VirtualHost git.local:80>
DocumentRoot "C:/Users/johndoe/github-projects"
ServerName git.local
ErrorLog "logs/git.local-error.log"
CustomLog "logs/git.local-access.log" combined
<Directory "C:/Users/johndoe/github-projects">
AllowOverride All
Order Allow,Deny
Allow from all
Require all granted
</Directory>
</VirtualHost>
This setup assumes that you ("johndoe" in this example) have a github
folder located here:
C:/Users/johndoe/github-projects
Note: This folder location should be tested to avoid permission issues that might not allow the server to access your files. i.e. put the github folder at the root-closest level that is comfortable.
Here's the complete file:
#
# Virtual Hosts
#
# If you want to maintain multiple domains/hostnames on your
# machine you can setup VirtualHost containers for them. Most configurations
# use only name-based virtual hosts so the server doesn't need to worry about
# IP addresses. This is indicated by the asterisks in the directives below.
#
# Please see the documentation at
# <URL:http://httpd.apache.org/docs/2.2/vhosts/>
# for further details before you try to setup virtual hosts.
#
# You may use the command line option '-S' to verify your virtual host
# configuration.
#
# Use name-based virtual hosting.
#
##NameVirtualHost *:80
#
# VirtualHost example:
# Almost any Apache directive may go into a VirtualHost container.
# The first VirtualHost section is used for all requests that do not
# match a ServerName or ServerAlias in any <VirtualHost> block.
#
##<VirtualHost *:80>
##ServerAdmin [email protected]
##DocumentRoot "C:/Program Files/xampp/htdocs/dummy-host.localhost"
##ServerName dummy-host.localhost
##ServerAlias www.dummy-host.localhost
##ErrorLog "logs/dummy-host.localhost-error.log"
##CustomLog "logs/dummy-host.localhost-access.log" combined
##</VirtualHost>
##<VirtualHost *:80>
##ServerAdmin [email protected]
##DocumentRoot "C:/Program Files/xampp/htdocs/dummy-host2.localhost"
##ServerName dummy-host2.localhost
##ServerAlias www.dummy-host2.localhost
##ErrorLog "logs/dummy-host2.localhost-error.log"
##CustomLog "logs/dummy-host2.localhost-access.log" combined
##</VirtualHost>
# this keeps http://localhost working
<VirtualHost *:80>
DocumentRoot "C:/Program Files/xampp/htdocs"
ServerName localhost
</VirtualHost>
<VirtualHost git.local:80>
DocumentRoot "C:/Users/johndoe/github-projects"
ServerName git.local
ErrorLog "logs/git.local-error.log"
CustomLog "logs/git.local-access.log" combined
<Directory "C:/Users/johndoe/github-projects">
AllowOverride All
Order Allow,Deny
Allow from all
Require all granted
</Directory>
</VirtualHost>
Lastly, we need to spoof a URL. Do this by adding a few lines to your hosts file:
/Windows/System32/drivers/etc/hosts
Open the above file and add:
127.0.0.1 git.local
Note:
This assumes that you want your main projects "URL" to be git.local
, but you can use whatever string is comfortable here just so long as it's not localhost
Now, start-up (or restart) Apache via XAMPP control panel, open a browser and visit:
http://git.local
That's all folks! <-- Unless you want to create an index.html directory of all your projects, which is recommended for ease of navigation