How to move Drupal site to local host


Testing a drupal site is a great deal when messing with PHP code and CSS files of modules and themes. For those reason move drupal site to local host for site owners (like DEV guy Vadim Shevchenko) rather backup and restore their drupal site to their local computer or other DEV enviroment, whereas move drupal site to local host for others (like SEO guy Ohad Golan) is no option but only work directly on production server.
To move drupal site to local host you should follow those instructions carefully:

1 .Backup all drupal files on server (usually to a ZIP file)

2. Backup drupal Database as follow:

Open PHPmyadmin on server < select the drupal database < go to “export” < press “go” (if no special configuration needed, than the regular option of “SQL” and “Quick” is fine).
We advise to ZIP the SQL file created for two reasons:
The ZIP operation will significantly reduce the file size.
The PHP.ini configurations might block files upload from a certain size (we can easily overcome this issue).

3. Install WAMP or XAMP server in windows to allow web services.
4. The most easy way to move drupal site to local host is to copy all files from section 1 to the localhost server (WAMP use WWW directory whereas XAMP use HTDOCS directory).
5. Login to PHPmyadmin in localhost < restore the database created on section 2 as follow:
Create black database < select the drupal database < go to “import” < choose the zipped (or not) SQL database file < press “Go”.
If from any reason the file size configurations won’t allow uploading this file < go to WAMP\XAMP PHP.ini file < change configuration under
“upload_max_filesize =256M” for example.
6. Now that we have files and database ready, go to www directory in XAMP\WAMP < go to “Sites< default” and edit the settings.php file as follow:

Change Database url under:
$db_url = ‘mysql://username:password@localhost/databasename’;
For example if you created DB named DEV before to import with user admin and password Login444 then the syntax will be:
$db_url = ‘mysql://admin:Login444@localhost/DEV’;

Change the row so that we can run update script once:
$update_free_access = TRUE;

Change site URL in the following row (to the directory drupal installed on):
$base_url = ‘http://localhost/drupaldev’;

7. Install the update script as follow:

Go back to setting.php < update row so that < $update_free_access = FALSE;

this is it – you just move drupal site to local host.

Common problems:

1. When linking to Administer or content you get error 404 page not found
Check your HTaccess file and add this code:
Require valid-user
Allow from
Satisfy Any

2. Check or add the following code under Apache < httpd.conf
AllowOverride all
Options Indexes FollowSymLinks MultiViews
Options Indexes FollowSymLinks

3. Check and disable the clean url module, as this is hard to get since you cant access the administration page and the module you can do it via SQL query when logged in to drupal database as follow:
Update variable set value=’s:1:”0″;’ where name=’clean_url’;
The “0” for disable and “1” to enable back.

If access to database is restricted due to permission you can always add a user to data base using this syntax:
insert into users (uid, name, pass)
values (8989, ‘admin’, md5(‘Password4444’);