Jun 5, 2008

Migrating a TYPO3 installation to a different server

This article tells how to migrate TYPO3 installation to another server. It assumes that you are in charge of the server. If you use shared hosting, it may be harder to migrate because you do not have anough control. In short migration consists from the following parts:
  • Migrating files
  • Transferring the database
  • Recreating directory structure
  • Updating the installation
Let's see these sections in details.

Migrating files

To migrate files, archive the following directories:
  • fileadmin
  • uploads
  • typo3conf
The rest will be recreated on the target server.

Transferring the database

Your source and target web servers should have the same character set and collation settings. You can view them using mysql command line utility:

show variables like 'character_set_%';
show variables like 'collation_%';


If these settings do not match, my.cnf settings on destination server should be adjusted. If changing my.cnf settings is not possible, you can put adjustments into setDBInit in Install tool. For example, to convert server fully to UTF8 for the current session, do:

SET NAMES utf8
SET SESSION character_set_server=utf8


The first command changes all settings except character_set_server. The second one changes settings for server. If that stays latin1 (not UTF8), most likely you will get weird errors (like "Field was not properly updated in the database") when saving records with non-English characters.

To backup database use the following command:

msqldump -u user -p --create-options --default-character-set=utf8 -K -e --opt -q database > database.sql

Options in italics are depended on your system.

When importing database on the target server use mysql utility with the same --default-character-set option:

/var/www $ mysql -u user -p --default-character-set=utf8
mysql> source database.sql

Recreating directory structure

Create directory structure as described in "Installing TYPO3 with upgrades in mind". Additionally create the typo3temp/ directory and any subdirectory in it that you had on the original server. There is no need to copy files from typo3temp/ to the new server. Unarchive files from the old server receating directory structure.

Change directory permissions on target server. Assuming that Apache group is apache, do the following:

sudo chgrp -R apache fileadmin typo3temp typo3conf uploads
sudo chmod -R g+wX fileadmin typo3temp typo3conf uploads


Notice the large "X". It means that permission is applied only to directories, not ordinary files.

Updating installation

Change database settings in typo3conf/localconf.php. Login to TYPO3. Go to Install tool and review basic settings. Set up ImageMagick directory and sendmail path if necessary. Check database using Database analyzer's COMPARE function.

Clear frontend cache. This is necessary because all images from typo3temp should be regenerated on the new host.

Verify that site works properly.

You are done with moving!

4 comments:

  1. Need Help!..My group is taking over the website from another vendor and all we got was the typo3-projectfile in .t3d which i have imported to the typo3 but i am still not able to run it successfully.

    ReplyDelete
  2. This is Greek. I need directions in simple English to tell me how to move my site from WEC to BlueHost. Surely there is an easier way to do this???

    ReplyDelete
  3. I had to stop at "archive these directories": I couldn't find a way to do any archives. Can you repeat this in plain English? I am just a volunteer, and we have already migrated- I am trying to migrate the site over before our year runs out with old server- next month!

    ReplyDelete
  4. Hi, Dima. Your migration process description looks too optimistic to me. When I've performed old domain search in the database I was migrating - I found lot of mentions. Some of them were in serialized data. I come up with a custom script to achieve that. But later I found nice search-replace tool which plays nice with serdata, here it is http://interconnectit.com/products/search-and-replace-for-wordpress-databases/
    Hope this will help someone.

    ReplyDelete