Most of the time we use our own, dedicated, hosting to stay clear of potential issues like safe_mode, memory limits or maximum file uploads. Sometimes however, a client wants or needs to stay at his own hosting solutions. In that case there are some things you should be aware of when moving the site with database from your development environment to the other server.

Howto start
Assuming you have done the required research at the new hosting provider (php version? mysql version?, does the mod_rewrite module exist in Apache for clean url’s? etc.), you should start following the same steps as described for updating a Drupal site in upgrade.txt: disable all non-core modules, switch to a core theme and set the site in off-line mode.

I also recommend turning of clean-urls, turn of any performance optimization (cache, compressed css) and flushing the cache.

The moving process is easy and should pose no problems:
1. transfer all files (ftp)
2. import the mysql database at the new host (if it’s a nice hosting provider they probably have phpmyadmin installed for users somewhere.)

Also if you run into a big .sql export file for your database which is too large to handle because of the file upload limit (often set at 2Mb), try zipping the file. This will dramatically decrease it’s filesize and phpmyadmin can handle .zip files.

Configuring the new site
First of all make you should of course update the database connection settings in settings.php. Going from MySQL 4 to 5 is not a problem but you need to bew aware to use the ‘mysqli‘ protocol for MySQL 5 instead of ‘mysql‘.

Also, don’t forget to make your files directory writable again. In case safe mode is turned on you must also make a custom writable temp dir in your web dir and configure the path in admin/settings/file-system.

Don’t forget to change the cookie_name for the correct domain in settings.php. And in case it’s a multi-domain, multi-site configuration you probably need to rename the directories for the correct domain names in /sites/*. If you only have the default directory no changes are needed. More information on this topic is commented in settings.php.

Your .htaccess file should probably be fine, but you may have to set the correct RewriteBase depending on the hosting environment. Read the comments in the .htaccess file and this page for more information. By the way: while you’re in the .htaccess file you may want to uncomment the www. prefix redirect.

Broken css? If you turn on clean urls (by running the test) and encouter a slow loading site with no style sheets, you need to set the correct $base_url in settings.php.

Memory limit issues
One problem you could encounter after a succesfull move is lack of sufficient memory on the server. This php.ini setting (memory_limit) can be anything but is most likely to be a number between 10 and 30mb. Yo can find this setting in a phpinfo() dump. And although you can sometimes override this setting in your .htaccess – most of the time you can’t because the hosting provider simply does not allow it.

So if you are getting a fatal error message like “Allowed memory size of X bytes exhausted (tried to allocate Y bytes)” you should probably rethink your modules.

On a 20 mb limit site, I occasionally got this error. This site was using some heavy modules though: CCK, Views, i18n and e-commerce. After disabling some smaller non-necessary modules I managed to keep it well under the limit, but apparently there are some pretty memory-hungry modules like Ubercart out there.

Finally
If everything is finally up and running, don’t forget to turn on performance caching, disable error logging to the screen and set up a cron job. If this is not allowed at the hosting provider, you can choose the poormanscron module.

[Post to Twitter] 

9 comments

  • anti-pixel says:

    nice tips ^^

  • [...] – bookmarked by 1 members originally found by ShiryuGL on 2008-08-10 A guide for moving a Drupal site to another server http://blog.merge.nl/2008/07/09/guide-moving-drupal-site-to-another-server/ – bookmarked by 4 [...]

  • Annalina says:

    Dude, I have moved to a more expensive hosting because I coudln’t do with 64Mb with my Ubercart website. Now I have over 100 MB guaranteed a a few days after setting up the web I am blankscreened again. What am I doing wrong?

    What are most memory heavy modules? I am not very familiar with PHP and server stuff and I was desperately looking for some readable advice for beginners on Drupal’s performance.

  • Albert says:

    100mb should really be enough.

    You should install the dev module. It shows you the memory used. One-by-one disable modules to see if one is using too much memory.

  • Steph says:

    What are the settings in PHPMyAdmin I should use when exporting my database?

  • Simone says:

    I’ve tried as you suggest, the site works good on the new server but as soon as I try to install a new module (tried with token, ecommerce and workflow) something strange happens.

    Usually I get a node access error (es: Fatal error: Call to undefined function: og_is_group_post_type() in /web/htdocs/www.xxxxxxxxxxxx.it/home/modules/og/og_access.module on line 95) every time I try to edit a node (befor the new module installation all works great).

    Permissions rebuild also doesn’t works (og_access.module on line xxx)

    Any suggestion ?

  • Albert says:

    @steph
    If you use phpmyadmin to import/export your database, it might be wise to compress (zip) the export. Otherwise, you might run into problems on low-end hosting and large files.

    @simone
    Seems to be someting with organic groups. I’m not sure if it is related to a drupal site which is moved.

  • Jan says:

    Hi – tried your guide – with success several times. But after moving the site seems to work – but when i have logged on and invoke any changes by pressing save – i am transferred to the old site! I think i have changed everything in settings.php. Any suggestions!?

    Br.

    Jan

  • Albert says:

    Is it a multilingual site? If so you might have set specifi domains for certain languages.

    If not try clearing the cache and search your database for the old domain.

What do you think?