Loading

How to transfer Magento from one server to another server

A step-by-step guide on moving Magento site from one server to another.

Step 1:
Enable maintenance mode

When you back up your data, no user can use shopping cart. Once you enabled maintenance mode, Users cannot access your website. To enable maintenance mode, create a file maintenance. Flag on your website root folder.

Step 2:
Backup files

Using FTP, you can copy all the files. But, there will be thousands of files in Magento. If you have SSH access, then it will be easy to compress the files into a single file and then download it.
You can zip files using the following command on SSH:

zip -r archive_name.zip *

Step 3:
Backup database

You can log in to phpMyAdmin to back up your database.
You can use mysqldump command to back up your Magento database, if you have SSH access

mysqldump -h hostname –u username –p password database_name > /path/backup.sql

You may also backup your database in compressed form:

mysqldump -h hostname –u username –p password database_name | gzip > /path/backup.sql.gz
mysqldump -h hostname –u username –p password database_name | bzip2 > /path/backup.sql.bz2

Step 4:
Upload files to new server

Once you downloaded all files and database backup from old server, now you can upload them into new server.

Step 5:
Extract files

This step is required only if you have compressed your files. Extract your compressed Magento database files. You can do this via File Manager (Cpanel).
If you have SSH access then you can extract compressed file through the following command:
unzip archive_to_extract.zip

Step 6:
Edit hostname

Edit the file and change it with exact mysql hostname, username, password, and database name.

<connection>
<host><![CDATA[YOUR_DATABASE_HOSTNAME]]></host>
<username><![CDATA[YOUR_DATABASE_USERNAME]]></username>
<password><![CDATA[YOUR_DATABASE_PASSWORD]]></password>
<dbname><![CDATA[YOUR_DATABASE_NAME]]></dbname>
<active>1</active>
</connection>

Step 7:
Provide files and folders permission

All files and folders should have 644 permission and 755 permission respectively to avoid “Internal Server Error” if your Magento files and folders permission is not correct.
You can change the file and folder permission settings via FTP.
In SSH, you can do through the following commands:

find . -type f -exec chmod 644 {} \;
find . –type d -exec chmod 755 {} \;

After that, you can adjust again the permission of ‘media‘, ‘var‘, and ‘app/etc‘ directory:

chmod -R 777 media var app/etc

Step 8:
Import database in new server

In the new server, create a new database. The data you have exported from the old server is now wil have to import to your new server with the help of phpMyAdmin.
If you have SSH access, you can restore/import database from the following command:
Restore plain sql database file

mysql -h hostname –u username –p password db_name < /path/backup.sql- Restore database as gzip compressed file (Linux)gunzip < /path/backup.sql.gz | mysql -h localhost -u username -p database_name- Restore database as bzip2 compressed file (Linux)bunzip2 < /path/backup.sql.bz2 | mysql -h localhost -u username -p database_name

Step 9:
Update base URL

You have to update base URL to your new website’s URL as shown below

UPDATE core_config_data SET value=”http://example.com/” WHERE path=”web/unsecure/base_url”;
UPDATE core_config_data SET value=”https://example.com/” WHERE path=”web/secure/base_url”;

That’s it, now you have successfully migrated your Magento website from one server to another.

Submit Your Comment