How to Copy/Move Magento

Learn How to Copy or Move Your Magento Website to a New Location

Create the new folder (if it does not exist)

The first step in moving or copying your website to a new location is to create the new directory. You can do that via the File manager tool or via your favorite FTP client. For more information on how to use FTP, you can check our FTP Tutorial.

Create a copy of the files

Once the destination folder is created, copy the website's files in it. Again you can do that via the File manager tool or over FTP client. You need to copy all files from the Magento website's document root to the destination folder. Make sure that you do not forget the .htaccess file which is hidden and might not be visible. To ensure hidden files are shown, select theĀ Show Hidden Files (dotfiles) checkbox that appears as a pop-up. Double-check if all related files have been copied to the new folder.

Create a copy of the database

Now you need to export your database.

For Magento 2.x

If you are not certain what is the database name, you may look it up in the env.php file. To export it, you may follow the instructions here. After you have your data exported, create a new database and import the content in it.

For Magento 1.x

If you are not certain what is the database name, you may look it up in the local.xml file. To export it, you may follow the instructions here. After you have your data exported, create a new database and import the content in it.

Reconfigure Magento accordingly

The next step is to alter the configuration file in order to match the new settings. All you need to change here is the database details at the new location.

For Magento 2.x

Those are stored in the app/etc/env.php file. The lines you need to alter are:

For Magento 1.x

Those are stored in the app/etc/local.xml file. The lines you need to alter are:

where:

  • yourhost should be the database hostname, most commonly - localhost;
  • your_user is a user that has full privileges to the database;
  • yourpassword is the password for the database user;
  • your_db is the complete database name for the database you are going to use with the transferred Magento.

The next step is to update the new Magento application's URL as shown in the article here. That is all. Your Magento should now be properly functioning at the new location.