Community Documentation

# Set up a Windows test server using XAMPP

Last updated July 2, 2010. Created by alpritt on July 25, 2007.

XAMPP for Windows makes setting up a local test server on your computer very easy. As well as providing the WAMP stack (Windows, Apache, MySQL and PHP) it includes both PHP versions 4.x and 5.x. It also includes PHPMyAdmin which is very useful for dealing with your MySQL databases.

The following instructions describe XAMPP configuration in some detail. A quickstart guide is also available.

(NOTE: XAMPP is only intended for use as a local test server which is available on your own computer. It has been created for ease-of-use, but not for production level security. If you want to tinker with security here is a guide about making XAMPP secure.)

## Installation

The installation of XAMPP is very straightforward. Rather than repeat the installation instructions here, just follow the instructions on the XAMPP site

Once you have downloaded and installed the package you may like to do some further configuration...

## Configuring XAMPP

### Creating virtual hosts

If you do not want to keep your files in the xampp/htdocs directory and type in a long URL for every page load, you can create virtual hosts for each of your sites instead. For example, you may like to keep all your sites in your My Documents folder for easy backup. Or you could create a root directory on your hard drive such as c:/sites/example/ which will make using shell commands easier. Wherever you choose to store your sites, you can always easily move them at a later date.

With XAMPP you set up virtual hosts in the following file:

\xampp\apache\conf\extra\httpd-vhost.conf

Open up that document in your text editor and append the following information to the bottom:

NameVirtualHost 127.0.0.1:80<VirtualHost 127.0.0.1:80>  DocumentRoot C:/xampp/htdocs/  ServerName localhost</VirtualHost>

The above only needs to be added once and you don't need to change any details to the above.

The next step, however, needs to be carried out for each site. Copy the code below and add it to the bottom of the file.

<VirtualHost example.local>  DocumentRoot "C:\path\to\your\site"  ServerName example.local  CustomLog "C:\path\to\your\site\logs\example.local.access.log" combined  ErrorLog "C:\path\to\your\site\logs\example.local.error.log"  <Directory "C:\path\to\your\site">    Options Indexes FollowSymLinks    AllowOverride All    Order allow,deny    Allow from all  </Directory></VirtualHost>

You will need to makes some alterations for your personal setup.

Where it says example.local put the URL you would like to type into your browser to find your site. You can call this what you like, but make sure it relates to the site you are creating and is not a real URL that you may like to access on the Internet otherwise you will get a namespace clash. Using the production site's URL but replacing .com or whatever with .local works well.

Where it says "C:\path\to\your\site" add the directory where your site is going to be stored on your local drive. Note that you should NOT include a slash on the end of the path. You can also set up a place to keep error and access logs for these sites. You will need to create the directory structure for these, but not the individual files (i.e. create the directory structure C:\path\to\your\site\logs but Apache will create the example.local.error.log file for you).

Finally you must include the domain names in your Windows host file. This file can be found at:

C:\WINDOWS\system32\drivers\etc\hosts

127.0.0.1 example.local

You can repeat this procedure for as many sites as you wish.

When you are done, restart Apache.

### Clean URLs

You will also probably want to enable clean urls. To do this in XAMPP, open up xampp\apache\conf\httpd.conf and find this line:

#LoadModule rewrite_module modules/mod_rewrite.so

and uncomment it by deleting the hash (#) so that it reads:

 LoadModule rewrite_module modules/mod_rewrite.so
Restart Apache and test that clean URLs work on your site. If this doesn't work for some reason, follow the instructions on this handbook page

### VirtualHost Tag

For me I had to put

<VirtualHost 127.0.0.1:80>  DocumentRoot "/path/to/your/site"  ServerName example.local......</VirtualHost>

for each vhost and not put the domain name in the VirtualHost tag.

Also by not putting the disk label in it runs fine with XAMPP Portable.

### log files

If you don't have directories setup for log files and you have these lines in:

CustomLog "C:\path\to\your\site\logs\example.local.access.log" combined
ErrorLog "C:\path\to\your\site\logs\example.local.error.log"

Apache won't start. If you're not sure if it's not restarting because of this, check your Apache error logs here: C:\xampp\apache\logs\error.log

If you want to make sure you didn't put something in wrong in your Apache configuration files, open the Command Prompt, go to c:\xampp\apache\bin and type apache -S for Apache to check your config files.

### log directory and files can be created manually!

if the apache is not starting because of the error log configuration, you can manually create the log directory and the files and try restarting! usually it can be a read/write permission error also in windows!

eV@gabond

### Another way via Winlamp

Hi all

There is yet another way to set up a test server.

I recently wrote a series describing step by step how to install a drupal test site on windows using winlamp.

http://www.cmstips.org/content/set-free-drupal-test-site-your-pc-winlamp-part-1

### Use of forward and backward slash

Hi, I tryed the virtual hosts in your example and clipped right from the page, seemed to work ok, but when I tried to use sub-directories in them and they would not work, I looked and looked around with no answer, then it dawned on me that its the slashes, then looked and most sites with virtual host examples showed using forward slashes, then I findly looked in Apache DOC later by a search on google for apache file name slash problem found the apache doc, and it says:

Note
When entering a file path on non-Unix platforms, care should be taken to make sure that only forward slashed are used even though the platform may allow the use of back slashes. In general it is a good idea to always use forward slashes throughout the configuration files.

Who would Know but them to always use forward slashes on all configuration files. easy mistake to make when you clip paths to config files in windows. So your second example is wrong above, now my sub-directories work
The apache mad slash disease. I guess if I used linux more often id know.

Bill Stark
SPC student

### Same problem with slashes

I switched out the back slashes and replaced with forward slashes and that did it for me. I also took out the error log lines because they were causing a problem for some reason (anyone's guess, I am a total amateur ; ).

My web files are stored off the root, in "web":

<VirtualHost 127.0.0.1:80>  DocumentRoot C:/web  ServerName localhost</VirtualHost><VirtualHost sitename.local>  DocumentRoot "C:/web"  ServerName sitename.local  <Directory "C:/web">    Options Indexes FollowSymLinks    AllowOverride All    Order allow,deny    Allow from all  </Directory></VirtualHost>

### I also took out the error log

I also took out the error log lines because they were causing a problem for some reason

Double check that you created the logs directory under your path. Apache will create the actual log files, but you must create the folder first.

I did everything here but couldn't get the site to work. Kept getting Object not found if I went to any page.

I didn't have .htacess in the drupal install (I think due to pathauto), so nothing I did would work. I copied .htacess to the directory and it works fine as of now.

### Xampp Version Needs to be posted here!

There directions are lovely, but NOTE when you click for the next page to start the Drupal install directions, the first line reads that Drupal 6 does not work on Xampp 1.7.2!!!

It needs to be noted on this page that the lastest version of Xampp SHOULD NOT BE INSTALLED and that version 1.7.1 should be, which is also a bit tricky to find. I managed to find it at http://sourceforge.net/projects/xampp/files/ but note that Xampp for Windows is a long way down the page and then you have to click on the version and the actual windows version appears below the MacOS version.

I have now spent more than 7 hours trying to rectify this first step blunder! Despite uninstalling 1.7.2, installing and reinstalling 1.7.1, I cannot get Apache actually running!

Being on a Windows Vista OS may have compounded things, but steps I've taken so far to try and get Apache working are:
- Turning off the Internet Information Services (found in the Control Panel)
- Confirming the "path to executable" for Apache in Windows Task Manager > Services is correct.
- Turning off User Account Control.
- Running Xampp's port scan program to confirm that Port 80 is available (which it is, but Apache cannot run). Verifying Xampp's port scan with another softwar (ScanPort).
- Changing Windows Firewall Settings to allow Apache through.

And I still cannot get Xamp working. So still cannot actually move on to my goal of installing and using Drupal.

If the version was clearly stated on this page, then all of the above could be avoided.

Hope this helps others.

### Yes 1.7.1 is right Candidate !

I have now spent more than 7 hours trying to rectify this first step blunder! Despite uninstalling 1.7.2, installing and reinstalling 1.7.1, I cannot get Apache actually running!

On Win XP, REINSTALLING the whole configuration in 1.7.1 sorted out my problems of Drupal installation.

### Installing Drupal

Marc Vangend suggested cross-reference between these three Drupal

documentation nodes (below). All three address How to Install Drupal and

XAMPP on a Home Windows Machine.

I wrote the first node for the absolute non-tech person. Like so many

bloggers out there, I wanted a Website readers can interact with and is easy to

maintain and "do it yourself." Drupal is perfect for that. However, for the non-tech person without access to a programmer, Drupal can be hard to install and set up.

The next two nodes (not mine) are great for more tech orientated users.

Please take a look at all three and see which one works best for you.

http://drupal.org/node/749846

http://drupal.org/node/307956

- DrupalBeginner

### Clean URL

I followed all the steps, and it kindda worked, now if I type http://example.local/drupal in my browser I can see my site, but what I'm trying is to do is getting that /drupal out of the url, because it will mess up the image cache module, I'm using xampp to run my site locally, so if I write http://example.local it redirects me to /xampp

Am I doing something wrong?

### You should set up virtual

You should set up virtual hosts for your different sites.

Edit your httpd-vhosts.conf and add a section something like this for each site you want:

<VirtualHost 127.0.0.1:80>  DocumentRoot /sites/diary/htdocs  ServerName diary.local  CustomLog "/sites/diary/logs/diary.local.access.log" combined  ErrorLog "/sites/diary/logs/diary.local.error.log"  <Directory "/sites/diary/htdocs">    Options Indexes FollowSymLinks    AllowOverride All    Order allow,deny    Allow from all  </Directory></VirtualHost>

Obviously you'll need to amend site names and paths as appropriate.

### Problems when following your directions httpd-vhost.conf

When I followed your httpd-vhost.conf advice above, it makes Apache stop working. I'm using the Xampp 1.7.3. After adding that code, when I'd try starting Apache, it would hesitate a long time, then finally say it was running, but the "Stop" button never appears, and the server does not function. I confirmed this with a Port Check, it said port 80 was open, which should be occupied by Apache.

Please amend the directions, as I went for hours trying to figure out what was wrong, not realizing this was it. Thanks.

### _

... same here .....

-----------
Good luck .....
... more recent results of trying Drupal just once are -
www.native-power.de
Malls and More

### Installation of xampp-win32-1.7.4-VC6.zip

1. I am installing xampp-win32-1.7.4-VC6.zip and modified httpd.conf file to switch from port from 80 to, let's say 8000. But the port to which apache is listening is still the same, 80.
2. Even on my personal pc I don't have enough privileges to modify C:\WINDOWS\system32\drivers\etc\hosts file.
Is there any way to get around this restrictions?
Bottom line, how to make it run?

Vitaly

### Got it working at last

I am using XAMPP 1.7.3. Had wasted a lot of time until I found this post.
Most of the other posts suggests that the "NameVirtualHost" be

NameVirtualHost *:80

But it didn't work for me as it kept directing me to the web root for all the virtual hosts.
So please take care to put this line properly.

NameVirtualHost 127.0.0.1:80

worked for me.

But it would be great if someone can explain the cause.
I will also try to find the reason and get back.

### Timeout during install on USB stick

Just an FYI for anyone who comes across this issue. I've just run through a Drupal 7.2 install under Xampp 1.7.4 and Windows 7 running Xampp from a portable USB pen drive. During the database table creation step (after you've entered the database name, username and password) the script timed out consistently for me. Editing maximum_execution_time in php.ini (I set it to 600) solved the problem. Don't forget to set it back to 30 afterwards.

### Installing using zend server

hi,
Someone point me out that zend server is better for such task(it is faster and optimized).
Is it true?

Perry.

### I've officially retired my

I've officially retired my winlamp Php v.5.14 ghetto development environment. Drupal 6.22 is getting too fancy and needs to run on php v5.2+, and Winlamp's website hasn't been updated in a couple of years.

So I've just recently jumped on the XAMPP bandwagon, ad I'm glad I did. Installation was a breeze, and setup was, too. I used the Installer download package. Whole process took ten minutes.

Now trying version XAMPP 1.7.7 on this eight-year old Dell laptop--

Apache 2.2.21
MySQL 5.5.16
PHP 5.3.8