The question:
I’ve been asking by a friend to develop his Magento site. His site is already up and running. And he is going to give me the access to the server that hosting his Magento site.
In order to develop some new features, I need to somehow clone his running Magento to a development environment.
Usually, I hosted all my Magento instance on Amazon AWS and I’ll just clone the instance and then launch another instance for development. Its easy to do it in AWS…
Anyone have any guidelines here that can help me? Maybe some blog teaching me how to clone an running Magento into a development environment?
thank you guys. Here Let me make the case more clear:
- Is the code under version control?
— no - Has the Magento site any modifications?
— Maybe - Does it use third-party modules?
— Pretty sure it does, - Do you know how to create a database backup?
— I have full access to the db and certainly I can create a backup.
The Solutions:
Below are the methods you can try. The first solution is probably the best. Try others if the first one doesn’t work. Senior developers aren’t just copying/pasting – they read the methods carefully & apply them wisely to each case.
Method 1
- Create and download a gzip of everything in the directory that the Magento site is in.
- Do a dump of the entire database. (if you have phpmyadmin, click the Magento database name on the left, then click Export on the top menu, then click “Go”)
- Upload and extract the gzip on your development server, in the directory you are using for Magento (usually web root, unless you have multiple sites).
- Create a database on the development server, and import the sql export from step 2.
- Edit
app/etc/local.xml
– change the database name, user, and password to match your new db. - In the new db, go to the core_config_data table, and change the
web/unsecure/base_url
andweb/secure/base_url
to the url of your development server (including any subfolders Magento might be in). Don’t forget a forward slash at the end of the url. - Delete
cache
andsession
in thevar
folder on your dev server.
After that, you should be able to navigate to the site at your dev server url. The admin path (devserver.com/admin, for example) will be the same as on the old server. Your file / folder permissions will need to be set as well – you can find info on that here : http://devdocs.magento.com/guides/m1x/install/installer-privileges_after.html
Method 2
• Export the database of your current Magento
• Create a blank database and import the database backup that you exported previously
• Once the database import done successfully, you will now have to change the secure and unsecure base_url in your newly created database. These can be found in the core_config_data table with following paths:
• web/secure/base_url
• web/unsecure/base_url
• Make a zip of files and extract it on new server.
• Open app/etc/local.xml file from Magento directory and edit following lines of code:
• <host><![CDATA[localhost]]></host>
• <username><![CDATA[username]]></username>
• <password><![CDATA[password]]></password>
• <dbname><![CDATA[dbname]]></dbname>
localhost: The hostname of your database server. Often this is “localhost.”
username: The SQL server username used to connect to the database.
password: The SQL server password used to connect to the database.
dbname: The name of the database you want to connect to.
• Delete everything from var/cache/ and from var/sessions/ of Magento directory.
• Finally in phpmyadmin, go to your new database and run the following SQL Query to reset store, group, admin and customer ids:
SET FOREIGN_KEY_CHECKS=0;
UPDATE `core_store` SET store_id = 0 WHERE code='admin';
UPDATE `core_store_group` SET group_id = 0 WHERE name='Default';
UPDATE `core_website` SET website_id = 0 WHERE code='admin';
UPDATE `customer_group` SET customer_group_id = 0 WHERE customer_group_code='NOT LOGGED IN';
SET FOREIGN_KEY_CHECKS=1;
That’s all, you are done.
All methods was sourced from stackoverflow.com or stackexchange.com, is licensed under cc by-sa 2.5, cc by-sa 3.0 and cc by-sa 4.0