How to move Drupal from one host to another
Ajay on December 26th, 2007Basically moving any php based open source packages from one host to another involve more or less same pattern.
Here I’ll explain how to move Drupal from one host to another.
Before you start working on it backup your files and database.
Step 1: Move files
The first step is to move all your files from one host to another by either using ftp or any other means as supported by your host.
Step 2: Move database (I’ve taken example of mysql database)
The 2nd step is to move database.
a) To move database first Export drupal database and save it as .sql
b) Then on your new host create a database from control panel or phpMyAdmin or any other means provided by host.
c) Then Import the .sql which you exported in step (a). You can do it either by phpMyAdmin or from SSH or any other means whichever is available to you.
Step 3 : Point Drupal on new host to the newely created database in Step 2
a) Database settings
When you moved your files in step 2, your Drupal installation still carries the references to old host.
You need to modify sites/default/settings.php file to use new database. To do so
Change the settings.php file permissions to make it writable. By default it is read only.
Open settings.php in any text editor.
Search for a line which is starts with
$db_url = ‘mysql:
This is the variable where you set the new database, username and password
The format of this line is:
$db_url = ‘mysql://username:password@localhost/databasename
Modify this line according to new database, username and password.
Make sure that the localhost is indeed your mysql host. In 99% it will be so, but if your host is 1and1 then you need to find your host from mySQL administrator and replace the lcoalhost also with the mysql host name which would be something db9131.oneandone.co.uk
b) Base URL change
If you have also changed your domain then you will need to modify following lines in settings.php file to have your domain.
$base_url = ‘http://www.example.com’; // NO trailing slash!
If you see any # at the beginning of this line then get rid of it.
Enjoy!!

I followed all the steps but don’t see the drupal install. Instead, I see a page with this:
<?php
// $Id: index.php,v 1.94 2007/12/26 08:46:48 dries Exp $
/**
* @file
* The PHP page that serves all page requests on a Drupal installation.
*
* The routines here dispatch control to the appropriate handler, which then
* prints the appropriate page.
*
* All Drupal code is released under the GNU General Public License.
* See COPYRIGHT.txt and LICENSE.txt.
*/
require_once './includes/bootstrap.inc';
drupal_bootstrap(DRUPAL_BOOTSTRAP_FULL);
$return = menu_execute_active_handler();
// Menu status constants are integers; page content is a string.
if (is_int($return)) {
switch ($return) {
case MENU_NOT_FOUND:
drupal_not_found();
break;
case MENU_ACCESS_DENIED:
drupal_access_denied();
break;
case MENU_SITE_OFFLINE:
drupal_site_offline();
break;
}
}
elseif (isset($return)) {
// Print any value (including an empty string) except NULL or undefined:
print theme('page', $return);
}
drupal_page_footer();
[Reply]
Avalon Reply:
January 12th, 2011 at 1:39 pm
@Avalon,
I had to also change the PHP settings in the .htaccess file. See info here:
http://help.godaddy.com/article/1082
[Reply]
Ajay Reply:
January 12th, 2011 at 2:28 pm
@Avalon,
That is php code and I bet you can’t see such code in browser.
[Reply]
@Ajay, sure might happen if PHP is not set up correctly
[Reply]
Ajay Reply:
May 26th, 2011 at 12:53 pm
@Nick,
Yes true.
Other day I saw php code showing up for a WordPress site. It turned out to be problem with config files.
It is scary to see php code, which opens door for devils
[Reply]