A guide for moving a Drupal site to another server

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.

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.

Drupal annoyances

Read More »


This is the company blog of
Drupal specialist Merge.nl

We are located in Breda (Netherlands) and build websites using Drupal. More about us.

Content on this blog is licensed under a Creative Commons Attribution-Noncommercial-Share Alike 3.0 Netherlands License.

Creative Commons License

Recent Comments