Magento Resource | E-Commerce Generation Explorer

Jun/09

29

How to move Magento from development to live server

First thing, we need make a backup of entire Magento database with all the default phpMyAdmin options. Also backup your database to .sql file.

Let’s suppose your development site is located at http://livesite.com/test and your live site is located at http://livesite.com.

So the second step for you would be to open the backup file you created at first step and do Search/Replace All from “livesite.com/test” to “livesite.com”.

Magento stores complete url paths inside the database. Therefore you’ll end up with database full of url paths. My backup file had total of 15400 occurrences of “livesite.com/test”. (I use EDITPLUS 2 to do that)

This is must do thing. Because of if you haven’t done replacement and have done import then basically your Magento on http://livesite.com would look for links of http://livesite.com/test like http://livesite.com/test/some-product-name.

If you search/replaced your .sql file do not rush to import it. If you try to import file as is, you’ll most likely get some errors from MySQL concerning foreign key constraint an so on.

Here’s how to fix this problem.

Open your .sql backup file again in your favourite editor (like EDITPLUS 2) and do the following steps.

Place these lines of SQL code on the top of the .sql file:

1
2
3
4
5
6
7
8
SET @OLD_CHARACTER_SET_CLIENT=@@CHARACTER_SET_CLIENT;
SET @OLD_CHARACTER_SET_RESULTS=@@CHARACTER_SET_RESULTS;
SET @OLD_COLLATION_CONNECTION=@@COLLATION_CONNECTION;
SET NAMES utf8;
SET @OLD_UNIQUE_CHECKS=@@UNIQUE_CHECKS, UNIQUE_CHECKS=0;
SET @OLD_FOREIGN_KEY_CHECKS=@@FOREIGN_KEY_CHECKS, FOREIGN_KEY_CHECKS=0;
SET @OLD_SQL_MODE=@@SQL_MODE, SQL_MODE='NO_AUTO_VALUE_ON_ZERO';
SET @OLD_SQL_NOTES=@@SQL_NOTES, SQL_NOTES=0;

Place these lines of SQL code on the end of the .sql file:

1
2
3
4
5
6
7
SET SQL_MODE=@OLD_SQL_MODE;
SET FOREIGN_KEY_CHECKS=@OLD_FOREIGN_KEY_CHECKS;
SET UNIQUE_CHECKS=@OLD_UNIQUE_CHECKS;
SET CHARACTER_SET_CLIENT=@OLD_CHARACTER_SET_CLIENT;
SET CHARACTER_SET_RESULTS=@OLD_CHARACTER_SET_RESULTS;
SET COLLATION_CONNECTION=@OLD_COLLATION_CONNECTION;
SET SQL_NOTES=@OLD_SQL_NOTES;

What is next? Please ZIP your .sql file and then do import of .zip file trough phpMyAdmin. This will help your will process more faster.

For example my .sql file was 6MB in size while .zip was 390KB. During the import you should not get any error messages.

Ok, for now you should have copied entire root folders/files of your Magento from livesite.com/test to root folder of livesite.com. There is only one more thing to do
before you can open you’re page in browser.

Having in mind that the root of your Magento is http://livesite.com you now need to open http://livesite.com/app/etc/local.xml file and modify it’s database connection information accordingly to your new database in livesite.com. Save the changes open your browser to livesite.com. Your Magento should be working.
But there are few things you need to check.

First you need to check folder write permissions trough FTP. Folders like /app, /app/etc, /var, /var/log, /var/session and so on, need to have appropriate access rights (755, 775, 777).

And there is one more thing that can cause problems. That is .htaccess file. If you’re moving a file from one site to another, and dumping it into same folder, then you probably won’t need to change this. But if you’re dumping it into some sub folder like http://livesite.com/store/ then you’ll have to write following into .htaccess file “RewriteBase /products/” and don’t forget your .sql Search/replace all to set it now replace of “http://livesite.com/test” with “http://livesite.com//products/” since you’re dumping Magento into sub folder.

·

5 comments

  • Lee Wilson · 14/03/2010 at 00:18

    Great guide this, I wish I had this guide a year ago, the key is that xml file, no realising that I needed to edit that file caused me no end of problems.

    Lee

  • Addon Solutions · 07/07/2010 at 15:11

    Hey,

    Its well written information here its depends on your local server you may need to update .htaccess file too as well database with few tables in which its has local URL written

    thanks

  • Soap Media · 24/08/2010 at 17:09

    Lost a morning to this export / import problem the above worked a treat. Much thanks

  • KL3CK · 22/03/2011 at 17:20

    Great tutorial. I knew how to move from dev to dev or live to dev etc but I think since Magento v1.4 I started having trouble with the “Foreign Key Restraints”. Hopefully this SQL script can make it smooth. Good point about overlooking the .htaccess file too.

  • Mike · 15/04/2011 at 10:06

    Excellent and very definitive guide – I was expecting this to be a horrible process, but from following this guide, publishing to my production server was a breeze!

    Thanks!

    Mike

Leave a Reply

<<

>>

Theme Design by devolux.nh2.me