atwix

Moving Magento To Another Server

Here I will outline the easiest process to move your Magento store to a different server/hosting. To perform the move, you should have access to the store files and database.

Step 1:

Clean var directory of your current magento installation to free some space and copy all magento files to a temp directory or directly to the new server. If you want to speed up the process, you should compress all files and extract them on the target server. Also create a dump of your current database and move it to your new server.

Step 2:

Once the files are copied, you should set the correct permissions for magento files and folders:
var and contents should have permissions “777″
media and contents should have permissions “777″
app/etc and contents should have permissions “777″

Restore your old database’s dump into a new database table you are going to use for the new store.

Step 3:

Now let’s set the new database connection settings in the file /app/etc/local.xml:

<resources>
    <db>
        <table_prefix><![CDATA[db_prefix]]></table_prefix>
    </db>
    <default_setup>
        <connection>
            <host><![CDATA[db_host]]></host>
            <username><![CDATA[db_user]]></username>
            <password><![CDATA[db_password]]></password>
            <dbname><![CDATA[db_name]]></dbname>
            <initStatements><![CDATA[SET NAMES utf8]]></initStatements>
            <model><![CDATA[mysql4]]></model>
            <type><![CDATA[pdo_mysql]]></type>
            <pdoType><![CDATA[]]></pdoType>
            <active>1</active>
        </connection>
    </default_setup>
</resources>

You need to replace db_prefix db_host db_user db_password etc.. with your values.

Step 4:

Open a db manager, such as PHPMyAdmin or similar and run the query below:

UPDATE core_config_data SET value="http://newhost.com/" WHERE path="web/unsecure/base_url";
UPDATE core_config_data SET value="https://newhost.com/" WHERE path="web/secure/base_url"

Where “newhost.com” is a new server domain name.
That’s all. Enjoy your old magento store on a new host. Also if you didn’t clean out your var folder in the previous steps – you should delete the folder var/cache now.



Enjoyed this post? us on Facebook and on Twitter to stay tuned.

  • inavas

    Hi, I did all the steps, but I can’t see the homepage nor the admin page. What can be the problem? No errors are shown, only blank page. Thanks.

  • Andrei

    you missed a step or two: creating the new database on the new server and importing data from the old one after backing that up.

  • http://tjosm.com/ Tharindu Kumara

    UPDATE core_config_data SET value=”http://newhost.com/” WHERE path=”web/unsecure/base_url
    Does this part necessary to setup on same domain?

    • http://www.facebook.com/yaroslav.andreevich.7 Yaroslav Rogoza

      Hi Tharindu. No, you can skip this step in your case.

  • http://www.facebook.com/iamanimator Deepak Upadhyay

    dont delete your VAR direcoty if you have magento 1.5 +