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.
  • 1
    Is the code under version control? Has the Magento site any modifications? Does it use third-party modules? Do you know how to create a database backup? - There can be many things that you would/could take into account, not to forget to think about how your changes come back to the production system as well.The code is normally cloned and the configuration deployed.
    – hakre
    Commented Jul 26, 2015 at 14:47
  • @hakre Can you be more specific about this? I mean, have you saw any online tutorials or blogposts that provide a systemical guidance for my problem? I don't want to mess things up and it highly likely that I'm going to mess it up. Also, in terms of how to apply changes in the production environment, its a problem too..
    – Fan Zhang
    Commented Jul 26, 2015 at 17:05
  • Have you already once setup a magento from scratch manually?
    – hakre
    Commented Jul 26, 2015 at 17:48
  • And for the tutorial situation, it really depends what you need. It can be from - to: Setting Up A Magento Staging Area, Magento Development Setup, Modern Magento Workflow and Development Tools - The normal processing is to start with the development box and then go through staging to live. Going through should be automated. Otherwise you take in problems from the current live setup that are hard to fight.
    – hakre
    Commented Jul 26, 2015 at 17:59
  • @hakre Pretty much every Magento I have, I set up from scratch. This is the only time I'm trying to clone a production Magento environment.
    – Fan Zhang
    Commented Jul 26, 2015 at 17:59

2 Answers 2

  1. Create and download a gzip of everything in the directory that the Magento site is in.
  2. 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")
  3. 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).
  4. Create a database on the development server, and import the sql export from step 2.
  5. Edit app/etc/local.xml - change the database name, user, and password to match your new db.
  6. In the new db, go to the core_config_data table, and change the web/unsecure/base_url and web/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.
  7. Delete cache and session in the var 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

  • Thank you for reply. Could you be more specific about the permission? What if the permission in the production environment has been modified to serve a special purpose? If I follow the link you provided, I pretty much "reset" the permissions to default.
    – Fan Zhang
    Commented Jul 26, 2015 at 17:02
  • 2
    The above is a general guide - so for each site you clone, you may need to make adjustments depending on your needs. Unless your dev server is running the same OS as the live server, you may actually need different file permissions to suit the OS. That being said, I would start with the above steps (1-7) and make adjustments to permissions and ownership from there. The file permissions can be maintained from the live server to the dev server, but with different users, etc, I generally find it easiest to configure the dev server as if starting from scratch.
    – AreDubya
    Commented Jul 26, 2015 at 17:55
  • 1
    Also - using tar, your file permissions will be preserved - askubuntu.com/questions/225865/…. Which could be helpful if those are the permissions you need for your dev server, but if not, you can use the link in my answer to "reset" them. @hakre makes a good point about deployment back to live, but I think that depends on your normal workflow, IDE, etc This answer only handles the cloning, but there are many options for deployment depending on how extensive the work is you will be doing, your workflow, time frame (changed data on live) etc
    – AreDubya
    Commented Jul 26, 2015 at 18:02
  • 1
    Also, it's a good idea to setup some form of mail catcher, you still want to test email functionality but obviously don't want to email real customers by accident! There's a great ruby gem called mailtrap, there's also services like mailtrap.io you can use by customising magento's SMTP settings. Really you should drop out the customer and order history on your dev site so you're not playing around with real customers private data.
    – benz001
    Commented Jul 29, 2015 at 9:24
  • 1
    This recipe also works for Magento 2, with the only minor change being that in step 5 you make the db info changes in app/etc/env.php, which replaced local.xml. Commented Dec 28, 2016 at 21:51

• 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:

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';

That's all, you are done.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.