A Completed Guide of Bring Magento from Dev model to Live
For lots of web developers out there, magento is an ideal open-source ecommerce system you may want to use if you clients want something comprehensive and sophisticated.
However, since it's a huge system, it actually not easy to bring the site from dev model to live model without config anything.
I have been struggling to make the make one of our magento site live. It takes quite lots of efforts, so i am hoping this article will save you time if you are in the same situation.
If you are using ftp, just tar them up and upload the your remote server and then extract it. (same with cpanel).
Clean Old Cache
The Magento cache system is useful but very annoying, if speeds up the page load and on the other hand, it will also saves session and cookies stuff within the original domain. So, please delete the content inside /var/cache and /var/session.
Check your files are at required permission, set chmod 777 to /var/.htaccess, /var and /app/etc
Change Config Files
If your live server using different database username, password or database name, you need to modify the config file from the file you have just uploaded.
Located to the file /app/etc then modify the local.xml file
<config> <global> <install> <date><![CDATA[Sun, 07 Aug 2011 23:46:53 +0000]]></date> </install> <crypt> <key><![CDATA[YOURKEY]]></key> </crypt> <disable_local_modules>false</disable_local_modules> <resources> <db> <table_prefix><![CDATA]></table_prefix> </db> <default_setup> <connection> <host><![CDATA[localhost]]></host> <username><![CDATA[YOURUSERNAME]]></username> <password><![CDATA[YOURPASSWORD]]></password> <dbname><![CDATA[YOURDATABASENAME]]></dbname> <active>1</active> </connection> </default_setup> </resources> <session_save><![CDATA[files]]></session_save> </global> <admin> <routers> <adminhtml> <args> <frontName><![CDATA[admin]]></frontName> </args> </adminhtml> </routers> </admin> </config>
One thing that tricks me for a quite long some time is DO NOT Double config the config.xml file. Looks like the local.xml will overwrite the default config.xml anyway. so Just leave it as default setting.
The Database is pretty confusing for Magento system. It runs lots of foreign key restrictions and check on its own database field and it always causes problem if you want to migrate the database from local to live.
So, after you export your database.sql file
please add the lines before the .sql file:
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;
Then, add the lines after the .sql file:
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;
Okay, After you done that, go to the live server and import the modified .sql to your target database. It should works no problem.
You may still not be able to access your website since the original setting may be different between local dev and live.
Next step, Go to the 'core_config_data' table and find the rows 'web/unsecure/base_url' and 'web/secure/base_url'. Replace the values of these rows with the corresponding values of your live store. [the url of your live website].
Then you will be able to see the site in action now.
Then you may find out, you cannot access your admin panel even using your correct username and password. The interesting things, there is no error message at all, you may feel no clue to this problem. Well, if you are in the same situation, please check your cookie domain.
The cookie domain in your db_config could be different with the live one as well, so that's why you having trouble accessing the user backend or login part of the system.
For instance, if you old cookie_domain is XXXX.dev you will need to change to XXXX.com[your live domain].
So still locate to the 'core_config_data' table in your database, and then change your web/cookie/cookie_domain to the value on your live domain.
Go back try to login again. You will be pleased to see it works.
Magento always has quite a lot to learn, let me know if you having any issue or problems with this article, i will try my best to help.