How to Migrate WordPress/Mysql from Ubuntu 12.04 32bit to Ubuntu 14.04 64bit

Introduction
I had a Ubuntu LAMP server running multiple WordPress sites. The Original install was done on Ubuntu 10.04 32bit server and later upgraded to 12.02 32bit. With the recent release of Ubuntu 14.04 only in 64bit I had to figure out how to migrate everything to a new installation.

After many failed attempts, I figured out a successful procedure as describe below:

Prerequisites
Install new Ubuntu 14.04 Server

Step One – Install and Setup New Server

Update with latest patches

apt-get update
apt-get upgrade

Set your host name

vi /etc/hostname

Update Networking (Static IP address and DNS setup)

vi /etc/network/interface

Edit the file to include the following entries

iface eth0 inet static
address 192.168.1.100
netmask 255.255.255.0
network 192.168.1.0
broadcast 192.168.1.255
gateway 192.168.1.1
dns-nameservers 192.168.1.1
dns-domain example.com
dns-search example.com

Install your Apache Webserver

apt-get install apache2

Install MySQL database server

apt-get install mysql-server libapache2-mod-auth-mysql php5-mysql

Install PHP

apt-get install php5 libapache2-mod-php5 php5-mcrypt

Create the Mysql Instance and update security

mysql_install_db
mysql_secure_installation

Install FTP Server

apt-get install vsftpd

Update vsftpd Config (Enable local user, Enable write capabilities, Disable anonymous)

vi /etc/vsftpd.conf

Step Two – Backup WordPress and Transfer Web Root and Mysql data

On your old server, archive the WordPress site Root Directories

tar -cf www.tar /var/www

Dump your mysql data

mysql -u root –p password

Execute the following SQL to quiesce and lock your database

FLUSH TABLES WITH READ LOCK;
SET GLOBAL read_only = ON;
EXIT
mysqldump --lock-all-tables -u root -p password --all-databases > dump.sql
mysql -u root –p password

Execute the following SQL to open the database

SET GLOBAL read_only = OFF;
UNLOCK TABLES;
EXIT

Transfer www.tar and dump.sql

scp www.tar username@hostname:Destination
scp dump.sql username@hostname:Destination

Step Three – Setup Apache and Virtual Hosts

On your new system, load your mysql data

mysql -u root -pdbmgr < dump.sql

Extract Web roots to /var/www

cd /
tar -xf www.tar

Create you virtual Hosts by creating /etc/apache/sites-available files for each WordPress site

cd /etc/apache/sites-available 
vi example.conf

Important note for Permalinks. WordPress sites need AllowOveride All directive
Example conf file (one for each virtual site)
Apache Conf file Example

 

 

 

 

 

Enable your virtual hosts

a2ensite example1.conf
a2ensite example2.conf

Enable Apache Rewite/.htaccess (Very Important for WordPress Permalinks)

a2enmod rewrite

Enable PHP Mcrypt (Needed for phpMyAdmin)

php5enmod mcrypt

Leave a Reply

Your email address will not be published. Required fields are marked *