I currently use a Windows XP Notebook and I wanted to setup a test environment on my PC to work on several drupal sites. The following is what I did to setup the test environment.

The software for my test environment

  • Windows XP Service Pack 2
  • Drupal 4.6
  • EditPad - I use this because it automatically saves files in the format they were created in (works great for UNIX text files)
  • SmartFTP
  • XAMPP 1.4.13 - includes: Apache HTTPD 2.0.53, MySQL 4.1.11, PHP 5.0.4 + 4.3.11 + PEAR + Switch, MiniPerl 5.8.3, Openssl 0.9.7f, PHPMyAdmin 2.6.1 pl3, XAMPP Control Panel 1.0, eAccelerator 0.9.2a, Webalizer 2.01-10, Mercury Mail Transport System for Win32 and NetWare Systems v4.01a, FileZilla FTP Server 0.9.6a, SQLite 2.8.15, ADODB 4.60, Zend Optimizer 2.5.7, XAMPP Security.
  1. Download the Latest Version of XAMPP at http://www.apachefriends.org/en/xampp-windows.html. Choose the Installer package. (Note: you might be tempted by XAMPP Lite because its smaller, but I had trouble getting it to work with drupal.)
  2. Install XAMPP.
  3. Create a drupal directory in xampp/htdocs
  4. Either copy your current drupal directory from your webserver or download and untar the drupal 4.6 from http://drupal.org/project/drupal. (You can use Winzip 9.0 to do this)
  5. You need to setup fake domain names to access your site on your local hard drive. First edit your windows/system32/drivers/etc/hosts file and add a line for each of your domains.
    127.0.0.1	domain.localhost
    

    Leave the .localhost so your fake domain names don't interfere with the internet.

  6. Setup virtual hosts for each of your domains. Edit the xampp/apache/conf/httpd.conf file and add the following lines to the bottom (note the first virtual host is so you can still access the xampp home page.)
    NameVirtualHost *:80
    
    <VirtualHost *:80>
        DocumentRoot "d:/apachefriends/xampp/htdocs"
    	ServerName localhost
    </VirtualHost>
    <VirtualHost *:80>
        DocumentRoot "d:/apachefriends/xampp/htdocs/drupal"
    	ServerName domain1.localhost
    </VirtualHost>
    <VirtualHost *:80>
        DocumentRoot "d:/apachefriends/xampp/htdocs/drupal"
    	ServerName drupal.localhost
    </VirtualHost>
    

    Add a virtual host for each of your domains. You may also want to create a drupal.localhost with a generic installation of drupal 4.6 for testing.

  7. Turn on mod_rewrite. While your editing the httpd.conf file, find the loadmodule section and remove the # to uncomment the rewrite_module.
  8. Start XAMPP, run xampp/xampp_start.exe. (Note: if you make any changes to your apache configuration after starting xampp, then restart it.)
  9. Create the drupal database and set database security. Go to xampp/mysql/bin and run:
    mysqladmin -u root -p password new-password 
    

    (change new-password to your desired password, when you are prompted for a password press enter there is no current password)

    mysqladmin -u root -p create drupal
    mysql -u root -p
    

    Now create a new user and password to access the drupal database
    GRANT ALL PRIVILEGES ON drupal.* TO nobody@localhost IDENTIFIED BY 'password'; (change nobody and password)
    Then type:

    flush privileges;
    

    Exit mysql by typing \q

  10. Download your current database. You can download your current database using phpMyAdmin, the drupal database.module or login to your webserver and type:
    mysqldump -uusername -ppassword -hremote_host database > backup.sql 
    

    (change username, password, remote_host and database to the correct values)

  11. Import your current database or create a new one. Go to xampp/mysql/bin and type:
    mysql -uusername -ppassword drupal < backup.sql
    

    To create a new database just change backup.sql to the database.sql in the drupal/database directory. (if you are using table prefixes then edit the database.sql and add the prefix to the beginning of each table name.)

  12. Add your new root password to phpMyAdmin. XAMPP comes with phpMyAdmin. If you changed the root password you will want to edit your phpMyAdmin configuration to add the new password. Go to xampp/phpmyadmin and edit config.inc.php. And your password between the single quotes on the following line.
    $cfg['Servers'][$i]['password']      = '';
    
  13. Setup your sites in Drupal. Create a directory under drupal/sites for each of your fake domain names. Copy the settings.php from the sites/default directory and change the db_url, base_url and db_prefix if necessary. Because the domains do not exist on the internet you do not need to delete these directories when uploading your site to your webserver.
  14. Download and install a editor. I use EditPad because it can edit UNIX files and my webserver is UNIX. You can download EditPad at editpadpro.com. There is a free lite version you can use if your site is not a commercial site.
  15. Download and install an FTP Client. I use SmartFTP because it works well and you can't beat the price! You can download it at smartftp.com.

There are a few other things you should be aware of.

  • XAMPP installs full web, mail and database servers. Since you are using this as a development environment, make sure you have a good firewall installed to protect from outside access.
  • You may want to edit your php.ini file so it matches the configuration on your server. The php.ini used by the apache server is in the xampp/apache/bin directory not the one in the xampp/php directory.
  • You can setup apache and mysql to start automatically as Windows Services by clicking the apache_installservice.bat in the xampp/apache directory and the mysql_installservice.bat in the xampp/mysql directory.

Thanks

JJ

Comments

smallfluffykat’s picture

I haven't tried it but this looks like something that should be added to the handbook? Anyone else think so? Looks wonderfully comprehensive...

travelingaround’s picture

Following your instructions, got xampp installed, with a fresh copy of Drupal 4.6 in the htdocs subfolder of my XP Home system.
The instructions for me get confusing at 11.
I keyed in the command with database.sql and get an error.

From reading elsewhere, figured out that I need to request a database.sql file from support to use as database.mysql can't be used.
This needs to be noted, and it would be helpful if there were a place to download this file for testing.

I'm using this to learn Drupal and use on a test machine prior to uploading to my web server.

kbahey’s picture

Please contribute this to the handbook. There are instructions there for Windows and Drupal, but they are out of date.

Your page will be a nice addition.

Better break it in two sections:

1. Installing a fresh (empty) Drupal installations.

2. Replicating your live web site at home, for testing or development purposes.

(Check the spelling when you do contribute it to the handbook (e.g. mysqldumb -> mysqldump)
--
Consulting: 2bits.com
Personal: Baheyeldin.com

--
Drupal performance tuning and optimization, hosting, development, and consulting: 2bits.com, Inc. and Twitter at: @2bits
Personal blog: Ba

micha_1977’s picture

just for debugging without IDE capabilities i use

the Version 2.11.32 PHP4.3 I686 of
DBG Debugger module for Apache
+ the free app maguma open studio from Maguma

works great with XAMPP

for real IDE's i suggest using ZEND Products or try eclipse[free] with PHPeclipse

...to be continued =)

-micha
work in progress with Drupal 4.6: langmi.de

travelingaround’s picture

Ok, reinstalled xampp and drupal. Got as far as #13 above where your sentence - "Copy the settings.php from the sites/default directory and change the db_url, base_url and db_prefix if necessary......
Ok, so does this mean I am to copy settings.php to each drupal/sites subfolder underneath c:/apachefriends/xampp/htdocs after possibly changing these settings?
what settings need changing for each settings.php? You only make a reference to changing the db_url, base_url and db_prefix but give no examples of, or if it is even necessary to change these default settings for a localhost test machine.
Also, when I followed your instructions and changed the config.inc.php password (in #12 section) to match the root password I changed in your #9 section, now I get an error for the phpmyadmin page in xampp - Cannot connect: invalid settings.

If more instructions were given here it would be a whole lot easier. Again, I am a newbie to Drupal. That's why I'm reading this page.
thanks.

Update--
Ok, got phpmyadmin to respond now and can see my database.
When I try to go to http://127.0.0.1/drupal/ I get the following -
Warning: mysql_connect() [function.mysql-connect]: Access denied for user 'username'@'localhost' (using password: YES) in C:\apachefriends\xampp\htdocs\drupal\includes\database.mysql.inc on line 31
Access denied for user 'username'@'localhost' (using password: YES)
So I gather I need to change these settings for each site folder they have been copied to??? - db_url, base_url and db_prefix

sepeck’s picture

You need to configure your settings.php file.

-sp
---------
Test site...always start with a test site.
Drupal Best Practices Guide

-Steven Peck
---------
Test site, always start with a test site.
Drupal Best Practices Guide

travelingaround’s picture

After searching everywhere I finally found instructions that applied to this file - http://drupal.org/node/258
Sigh.. I do consider myself a newbie when it comes to Drupal but not for technology in general. There needs to be better documentation here, that is centrally located and concise for Linux AND Windows fresh installs. Many will not look as I did and will go with another CMS out of frustration.

sepeck’s picture

I have yet to understand this type of comment.
How much clearer can the location be stated then the method it uses IN the INSTALL.txt file included with the download? Including the INSTALL.txt file in downloads is a time honored tradition for Internet programs.

4. CONNECTING DRUPAL

The default configuration can be found in the
'sites/default/settings.php' file within your Drupal installation.
Before you can run Drupal, you must set the database URL and the
base URL to the web site. Open the configuration file and edit the
$db_url line to match the database defined in the previous steps:

$db_url = "mysql://username:password@localhost/database";

where 'username', 'password', 'localhost' and 'database' are the
username, password, host and database name for your set up.

Set $base_url to match the address to your Drupal site:

$base_url = "http://www.example.com";

-sp
---------
Test site...always start with a test site.
Drupal Best Practices Guide

-Steven Peck
---------
Test site, always start with a test site.
Drupal Best Practices Guide

travelingaround’s picture

Yes, found that after digging through. Got it running on my test machine. Maybe someone can organize a recent chm windows help file to include recent 4.6 Drupal install and FAQ documentation. Part of my problem is the little time available to tinker around with.

jo1ene’s picture

Will this work? I attempted the set up with one alteration. For step 5...

windows/system32/drivers/etc/hosts

wasn't in the right place but I copied it there as well as added the line of code where it was in the windows folder.

I get to step 8 (start up). When I try to get into mysqladmin, a window flashes by and that's it. I have zonealarm, but chose to allow the server permissions.

winmysqladmin runs but that doesn't fit your instructions.

Can I not do this on my machine or did I screw up step 5 or 6?

Geary’s picture

On Windows 95/98/Me, the hosts file has a different name and location. The file is:

\Windows\LMHOSTS

where Windows is installed in the default directory named \Windows - change this if you have a different installation directory.

There is a sample file you can look at in the same directory called LMHOSTS.SAM.

The format of the file is basically the same as the hosts file on Windows NT/2000/XP.

stevensj2’s picture

This is great!

I set it up without doing the domain name stuff, and just did it as simply as possible and it works great.

I previously used UniSever, but this much better :-)

mork’s picture

I really appreciate the instructions... I am about to go ahead and do it. At some point you say "now go to /blah/mysql/bin" and type "foo".

This is gonna catch some people. Since XAMPP (currently downloading) comes with phpMyAdmin it might be easier to just say "go to http://localhost/phpmyadmin and do the following couple of thing" (you can create the DB, the user, and import the sql file all right there).

I'm not familiar with this XAMPP package, but I'm looking forward to it. Sounds like it's just click and go :)

sepeck’s picture

but why? why use the gui when the cmd line interface ... A. works and B. is in the written docs? Using phmyadmin the next new user question is How do I create a database in phpmyadmin? :)

You are welcome to add instructions to this thread tho, that's the beauty of Open Source.

-sp
---------
Test site...always start with a test site.
Drupal Best Practices Guide

-Steven Peck
---------
Test site, always start with a test site.
Drupal Best Practices Guide

mork’s picture

just a comment. I used your command line instructions myself. However, if you hadn't provided them I would've used phpMyAdmin to do it. I don't do enough MySQL management to know the commands and stuff.

Also, got it working no problem. Can't seem to turn php warnings off for the life of me for some reason (be it via php.ini or .htaccess) but I'll live.

sepeck’s picture

I knew nothing about MySQL when I started this. It was.. painful. So I understand, but learning the basics does prove worth it in the end. There is nothing wrong with phpmyadmin, but having an understanding of how the underlying structure works is the difference between using a tool through rote instructions and understanding the tools you are using. All of it starts somewhere.

-sp
---------
Test site...always start with a test site.
Drupal Best Practices Guide

-Steven Peck
---------
Test site, always start with a test site.
Drupal Best Practices Guide

kbahey’s picture

jdmquin

I have managed to setup Drupal with Windows and XAMPP.

Everything works fine except that clean URLs give 404s. I tried setting RewriteBase to / but that did not affect anything.

Any idea how to get clean URLs with XAMPP?

--
Drupal development and customization: 2bits.com
Personal: Baheyeldin.com

--
Drupal performance tuning and optimization, hosting, development, and consulting: 2bits.com, Inc. and Twitter at: @2bits
Personal blog: Ba

Marco Palmero’s picture

Yep... Still stuck...

got the same problem - does anyone here know the solution?

---------------------------------------------------------
My Blog - Photography, travelling and University...

sepeck’s picture

I don't use Apache, but I believe it is an Apache configuration problem. You need to to make sure that something like Allow Overwrite ..... whatever the swtich is that allows mod_rewrite to work is on. I realize it's not a clear answer, but hopefully you can find it in the Apache docs.

-sp
---------
Test site, always start with a test site.
Drupal Best Practices Guide -|- Black Mountain

-Steven Peck
---------
Test site, always start with a test site.
Drupal Best Practices Guide

TisKicking’s picture

I recently sat up a drupal test server using xampp. I followed the instructions from this topic and in the end, I got the thing working.
Unfortunately, another program that uses a mysql-database now doesn't function anymore!
It appears that the program can't connect to the database. The error-messages goes like this (and I have read the same thing in this topic):

"-2147467259 [MySQL][ODBC 3.51 Driver] Access denied for user 'presys'@'localhost' (using password: YES) Retry?"

Presys is the name of both the program and the user.

When installing drupal, I created a new user. I think this implicated that I have deleted the old user. How can I remake that user and make the thing working again?