Moving to another server


Please follow these docs to setup the LAMP stack on the server

Initialize the server for the first time

Install Apache v2.4

Install MySQL v5.7

Install PHP v5.6

Install Redis v4

Install Apache PageSpeed module:


sudo dpkg -i mod-pagespeed-*.deb

sudo apt-get -f install

sudo systemctl restart apache2

Get started

Connect into the OLD server and set the magento site into maintenance mode

Note: Only do this when you’re going to completely move server in on shot! For testing new server only, should keep the old server running until we decide for a final move!

cd /var/www/html/magento

touch maintenance.flag

Then on the NEW server, clone the source code

cd /var/www/html/

git clone

sudo chown -R www-data var/ js/ skin/ media/

Sync the latest “media” files

cd /var/www/html/magento

rsync -av root@$OLD_SERVER_IP:/var/www/html/magento/media/* media/

sudo chown -R www-data media/

Copy the latest db dump file into the server, see more about how to backup & restore MySQL

cd ~

scp root@$OLD_SERVER_IP:/root/easyshed_prod.sql.gz .

Create new database and user

mysql -uroot -p -e “CREATE DATABASE easyshed CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci;”

mysql -uroot -p -e “GRANT ALL ON easyshed.* TO ‘easyshed’@’localhost’ IDENTIFIED BY ‘’; FLUSH PRIVILEGES;”

Restore the db dump

gunzip -c ~/easyshed_prod.sql.gz | mysql -uroot -p easyshed

Create local config file, and update the db connection info

cd /var/www/html/magento/

cp app/etc/local.xml.template app/etc/local.xml

vi app/etc/local.xml

Copy Apache config files from old server, or create new one per these documentation:

To test the new site first on different domain, e.g:

mysql -uroot -p easyshed -e “UPDATE core_config_data SET value = replace(value, ‘’, ‘’) WHERE path like ‘web/%'”

Remember to revert it back before switching the DNS!

Once everything is tested and ready, go to DNS management site of the domain and point the domain to the new IP address.

The last step is setup the crontab on NEW server. Go to the OLD server, copy the out of this command

crontab -u www-data -l

paste it to the crontab of NEW server

crontab -u www-data -e

You’re all set!

Leave a Reply

Fill in your details below or click an icon to log in: Logo

You are commenting using your account. Log Out /  Change )

Google photo

You are commenting using your Google account. Log Out /  Change )

Twitter picture

You are commenting using your Twitter account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )

Connecting to %s