Jul 21, 2012
kalpesh

Migrate magento to new server / domain / database / host

Move or migrate magento to new server, domain, database, host, anything by following the steps below.

To configure your Magento with a new domain, you will need to do following steps:

- Copy whole Magento project from current server and paste it to the new server.
You can do server-to-server transfer. First, tar.gz your magento project
tar -cvf magento.tar.gz magento
Then copy it to your new server from old server
scp magento.tar.gz root@your.ip.address.here:/var/www/.

- Backup the database (Admin -> System -> Tools -> Backup)
You can also take backup through phpMyAdmin, or by mysql.
mysqldump -u user -p database > /path/to/keep/db.sql

- Logout from your old server. Login to new server.
Extract the file magento.tar.gz that you sent from old server
tar -zxvf magento.tar.gz

- Delete all directory or files that are there in cache folder
rm -rf var/cache/*

- Edit local.xml that is in magento/app/etc/local.xml and change mysql username, password, database as per new server credentials

- Import the backed up database. Before that create empty database to dump tables in it.
mysql -u root -p 'password';
create database dbname;
exit;
mysql -u root -p -d dbname < /path/to/your/db.sql

- Edit the database to change it to your new domain name. Search in core_config_data table for old domain.
select * from core_config_data where path like '%secure/base_url';
and update it with your new domain
update core_config_data set value='http://mysite.com/' where path like '%secure/base_url';

5 Comments

  • Hi
    Thanks for your posting, it’s been a great help.
    Although i’m having an issue trying to transfer via scp the tar.gz file.

    I’ve tried this two options

    Option 1: Logged at Old Server via SSH

    scp magento.tar.gz root@IPADDRESS:/var/www/.

    The error in this case is
    /usr/bin/ssh: no such file or directory

    Option 2: Logged at new server via SSH

    scp OLDUSER@OLDURL:/var/forojardin.com.ar/htdocs/magento.tar.gz /var/www/

    The error in this case is
    ssh: connect to host forojardin.com.ar port 22: Connection refused

    Do you know what could be the problem?

    Thank you

    • Hi Esteban, the error is because SSH is not installed in your system. Make sure both the machines have SSH. SCP uses SSH to transfer files between servers. In Ubuntu we generally do with sudo apt-get install openssh-server to install OpenSSH.

      • I guess you’re right. In OLDSERVER i think openssh it’s not installed.
        The problem is that i don’t have root access in that server. Only SSH access to manage files, etc but i cannot install anything.

        Is there another way to transfer the file? Becasue it’s 1,5GB

        Thank you so much for your response

        • Try with FTP

  • Great tutorial! Very Helpful, thanks

Leave a comment

 

Welcome to my Blog

Kalpesh MehtaHelping Magento developers in their day-to-day development problems since 2011. Most of the problems and solutions here are my own experiences while working on different projects. Enjoy the blog and don't forget to throw comments and likes/+1's/tweets on posts you like. Thanks for visiting!

Certifications