Moving Drupal from PHP4 MySQL4 and Apache 1 to newer versions

Recently I faced the problem of moving one of our drupal sites to a new environment. I had several problems, which probably are quite common. Here it is what one have to do – step by step.

My settings are (Drupal 4):

Old server: Apache 1.3, PHP 4.4.4, MySQL 4.1

New server: Apache 2.0, PHP 5.2.2, MySQL 5.0.40

1. Make a backup of the site (database and files)

Do full MySQL dump (preferable with DROP commands). It's easy to do with stuff like PHPMyAdmin. With a mysqldump command just do:

mysqldump -u db_user -p databasename --add-drop-table > filename.sql

Copy the filestructure to the tar.gz file. Use FTP client or:

wget -r ftp://user:password@ftp.server/
tar cfvz ftp.server.tar.gz ftp.server

2. Install on the system

One may copy the SQL files first to the server – always depends on local/server configuration.

If needed convert the SQL file encoding to UTF:

iconv -f ISO-8859-1 -t UTF-8 ~/database.sql > ~/database.utf.sql

and change standard encoding

vi database.utf.sql

Install remotely using PHPMyAdmin or copy it to the server (I prefer secure shell) and inject it into the system.

Copying (on local machine)

scp database.sql user@webserver:

Injection (on the server):

mysql -u db_root -p database < database.utf.sql

Set access to the database

mysql -u db_root -p database
GRANT all on database.* to db_user@localhost identified by 'password'

Copy the filestructure – use your preffered method…

scp ftp.server.tar.gz user@webserver:
cd /var/www/vhosts
tar xfvz ~/ftp.server.tar.gz

Give apache write access to some directories

sudo chown -R apache:apache files

edit sites/default/set­tings.php if needed (i.e. different db_user)

3. Fix environment differencies

(After drupal bugtrack ) Add session_write­_close() on the end of index.php to solve the problem with not saving session data.

I found also a weird thing. On the old server the RewriteCond

RewriteCond %{REQUEST_FILENAME} !-f

didn't catch the something.html if the address was /something, on the new site it was doing it. I simply move these rubbish into the other folder and everything worked fine.

Trackback URL for this post: