Composr Tutorial: Moving sites

Written by Chris Graham (ocProducts)
This tutorial will explain how to move servers.

Do not install Composr on the new one – transference is done at the file and database level, not by importing Composr data into a new installation.

The Composr quick installer handles all the work to installing Composr on a server automatically. However, if you choose to move to another server, some of this work will need to be re-done. This tutorial will explain the issues involved here.

This tutorial is written around moving servers. If you are moving hosting accounts within the same server you can follow the same process. If you are merely changing URLs within the same hosting account then all you need to do is move the files (if appropriate) and change the base URL setting (see "Changing URL").


Introduction

There are two fundamental parts to a Composr site:
  1. The files
  2. The database

To copy to another server/hosting-account, you would need to copy both.

Files

Composr has an enormous number of files. The quick installer extracts all of these to the server so that you do not need to be concerned with transferring them individually.

The good news is that most webhosting control panels come with high quality file managers. To transfer files follow the following process:
  1. Log in to your control panel in the old server.
  2. Proceed to the file manager.
  3. Zip up the contents of the directory Composr is installed in (it's best to ZIP up everything within the directory via mass-selection, rather than zipping the parent directory).
  4. Download the ZIP to your machine.
  5. Upload the ZIP to the new hosting preferably using SFTP/FTP (using a file manager is very likely to time-out). Put it in a place equivalent to where it was generated on the old hosting.
  6. Log in to your control panel in the new server.
  7. Proceed to the file manager
  8. Unzip the ZIP file.

If you are a very advanced user you can avoid steps 4-8 by directly transferring the ZIP from one server to another and unzipping from the shell. This is beyond the scope of this tutorial, however.

File permissions

Once files are transferred, you need to replicate the correct file permissions so that Composr can continue to function. File permissions are rarely transferred when actual files are transferred, due to the relationship between permissions and ownership credentials and the differences between ownership credentials on different servers.

If you are on a suEXEC-style server you can bypass this section. Most users nowadays are.

If you have 'shell access' on your new server, typing the following from a shell inside your Composr installation directory will quickly fix your permissions to what they should be:

Code (Bash)

chmod +x fixperms.sh
./fixperms.sh
 

If you do not have such access:
  1. Try asking the webhost to do it
  2. You can get Composr to set the permissions for you using a special feature you'll find in the http://yourbaseurl/upgrader.php script.
  3. If all else fails, you need to change any permissions described in the Advanced installation tutorial and any files that were created/uploaded during running the site. This could be incredibly time-consuming, so is not recommended.

Database contents

Almost your site data is stored in the database so it is crucial that database contents is backed up, transferred, and restored, to the new server.

Backup is best done using the shell, via the mysqldump command.

Code (Bash)

mysqldump -uusername -ppassword database > filename.sql
 
Download the .sql file to your machine. This file is called an "SQL dump".

If you can't use the shell

Reasonable webhosts allow you to directly download an SQL dump via phpMyAdmin. mysqldump is preferable as it is more reliable, but phpMyAdmin usually works. Be aware though that bad webhosts pretend to but it ends up timing-out with an error message and/or a truncated file.


Upload the SQL dump to your new server using SFTP/FTP.

Restoration is then best done via the mysql command:

Code (Bash)

mysql -uusername -ppassword database < filename.sql
 

If you can't use the shell

If you don't have shell access to import a database you'll probably end up using phpMyAdmin again to restore. However you will struggle to import large databases with this, as it is much more problematic restoring than backing up. You may therefore find this tool useful: http://www.ozerov.de/bigdump/.


If the new database settings are different to the old ones, you will need to use the http://yourbaseurl/config_editor.php script to update your Composr settings (or edit _config.php by hand).

You may need to update the following settings:
  • db_site
  • db_site_host
  • db_site_user
  • db_site_password
  • db_forums
  • db_forums_host
  • db_forums_user
  • db_forums_password

Changing URL

If you are moving URLs, then you need to use the Installation Options editor (the http://yourbaseurl/config_editor.php script) to change your base URL setting. Composr automatically will clear out your caches if it sees the base URL has changed.

Caches

You should clear the block cache from in the http://yourbaseurl/upgrader.php script.

See also


Feedback

Please rate this tutorial:

Have a suggestion? Report an issue on the tracker.