Copy a site to a local XAMPP installation
Here are the steps necessary to get a copy of a Drupal website a local computer for development purposes, using the XAMPP stack and a variety of tools. Many of the steps taken here have been made so that you can keep your PHP files outside the standard htdocs DocumentRoot directory of the Apache server while maintaining whatever else you have running on your XAMPP installation.
1) Install XAMPP software. This gets you Apache, MySQL and PHP all set up in a few clicks. Skip this step if you have them already set up (Drupal needs things like php and mod_rewrite in your Apache build.)
2) Download a copy of your production 'drupal' database to your local MySQL server. If your production server has phpMyAdmin you can export your database using it and then import using your local phpMyAdmin. You may also use a program like Navicat MySQL since it handles UTF-8 data properly (unfortunately my favorite free MySQL client, SQLyog, seems to lack proper UTF-8 support).
3) Create a user on your local mysql database to match the remote connection settings and give them full permissions:
% mysql> GRANT ALL PRIVILEGES ON drupal.* TO 'drupaluser'@'localhost' IDENTIFIED BY 'drupalpassword' WITH GRANT OPTION; FLUSH PRIVILEGES;
4) Get a copy of the production Drupal site files and folders (In my case, I use a source control system client like Perforce) and copy them to a location you want to do your work in. An example: C:/p4/atlas-drupal/drupal. I will call this location %your_drupal_files% from here out.
5) Edit %your_drupal_files%/sites/default/settings.php and change the base URL to $base_url = 'http://localhost/drupal'; You should still be able to leave the $db_url connection setting alone.
6) Edit %your_xampp_location%\apache\conf\extra\httpd-xampp.conf and add the following lines according to where your copy of drupal lives on your computer:
Alias /drupal "%your_drupal_files%/"
<directory "%your_drupal_files%">
AllowOverride FileInfo Limit Options Indexes
Order allow,deny
Allow from all
</directory>You'll need that "
FileInfo" directive if you are getting 500 errors in your Apache error log like "RewriteEngine not allowed here". You could also add these lines in standard httpd.conf if you are not using XAMPP but just plain Apache.
7) (Skip this step if you are using regular Apache and not XAMPP)
Edit %your_xampp_location%\apache\conf\httpd.conf and uncomment out the line LoadModule rewrite_module modules/mod_rewrite.so You need this so Drupal can have "clean links".
8) Edit %your_drupal_files%/.htaccess and change the RewriteBase to /drupal.
9) Restart the Apache service (with the XAMPP control panel if you are using XAMPP)
You now should be able to navigate to your sandbox development copy of the site via http://localhost/drupal
