Installing a local copy of a Drupal website
Here are the steps you need to take to get a copy of a Drupal website onto your 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 all set up in a few clicks. Skip this step if you have both 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. I suggest using 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:
GRANT ALL PRIVILEGES ON drupal.* TO 'drupaluser'@'localhost'
IDENTIFIED BY ‘drupalpassword’ WITH GRANT OPTION;
FLUSH PRIVILEGES;
4) Get a copy of the website’s PHP files for your Drupal installation (In my case, 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 AuthConfig FileInfo
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
This post is filed under Computer Science. You can follow any responses to this entry through the RSS 2.0 feed. You can leave a response, or trackback from your own site.
June 30th, 2007 at 3:54 am
I tried what u have said here..installed the latest XAMPP..and it hasnt worked..
can u tell me if something has changed..
i also am not able to restore my backed up dbase from the live site to the test location..
pls help..i get errors of time out..and also errors like..
#2006 - MySQL server has gone away
pls help
thanks
June 30th, 2007 at 12:54 pm
Your problem is with MySQL, try googling for that error message, it could be a variety of reasons why the db server isn’t responding.