A Quick Guide On How To Move Your Magento Store To A New Server
The pleasures of setting up a Magento website is beyond any comparison. The charm of this platform is undeniable, and its best of breed features give Magento a sense of grandeur. The platform offers every clear opportunity to online retailers to add wings to their stores and widen its scope. What Magento has to offer is striking customization capabilities, and as your business grows, you can easily migrate your store to a brand new server.
There are various reasons in the favor of moving a Magento powered store to a new server. For example- you might be looking for an upgraded server, or you are dissatisfied with the current hosting service provider. Whatever the reason may be- the process of migrating a Magento site to a new server is a hard nut to crack. There are various challenges and details involved that developers need to take care of while executing the job.
Well, switching to another server can be a nerve-wracking experience, but there is a step-by-step process you can go through to ensure a hassle-free transition. This article talks about all those steps that need to be taken at the time of making a big switch.
Make some preparations
While transferring your Magento store to a new server, it is important to make sure that your chosen server is reliable enough to ensure a smooth functioning of your online store. Double check if it has enough disc space, it can minimize the amount of downtime, and it should be capable enough to store your store completely.
Create a backup
Your website backup is very critical if you seriously want to avoid catastrophic situations. We frequently advise our client not to underestimate the importance of backing up a website files and its copy so that you can have a peace of mind. Also, it is necessary to examine your changes, so that they don’t hinder your website performance.
Once you have a backup of your website and you are sure of about your new server, it’s time to implement the steps related to the migration process.
Your next step is to create a website and its database for your online shop powered by Magento. After this, you can create a backup of all your files as well as database. Make sure to reduce the size of your backup file by excluding, var/cache, var/full_page_cache, var/log, var/report, var/session.
cd /home/mageold/public_html
tar -czf ~/magento-files.tar.gz --exclude=var/cache --exclude=var/full_page_cache --exclude=var/log --exclude=var/report --exclude=var/session .
mysqldump -h localhost -u mageold_magento -p mageold_magento | gzip > ~/magento-db.sql.gz
If you want an easier way to migrate the backup files to the server, then you can take the benefit of SCP:
scp ~/magento-files.tar.gz ~/magento-db.sql.gz magenew@newhost:
After this just remove the copy of backup from the server:
tar -xzf ~/magento-files.tar.gz -C /home/magenew/public_html
gzip -dc ~/magento-db.sql.gz | mysql -h localhost -u magenew_magento -p magenew_magento
Install the transferred Magento back up files
In this step, you need to start editing the app/etc/local.xml file and add a new setting for database. The settings will be created by modifying the access permissions. The two variants which need to consider here are:
- the web server executes scripts on account of user who owns these files
- the web server executes scripts on account of an individual user
For 1st variant, the permissions should be defined like this:
find /home/magenew/public_html -type f -print0 | xargs -r0 chmod 640
find /home/magenew/public_html -type d -print0 | xargs -r0 chmod 750
Now, you give permissions to the web server to save all the files.
find /home/magenew/public_html -type f -print0 | xargs -r0 chmod 644
find /home/magenew/public_html -type d -print0 | xargs -r0 chmod 755
chmod -R a+w /home/magenew/public_html/{app/etc,media,var,includes}
Test your site
At this point, you need to redirect your website to the new server. This can be done by adding the below mentioned line to the host file.
For Unix- /etc/host
For Windows- %SYSTEMROOT%system32driversetchosts
1.2.3.4 yourdomain.com
The 1.2.3.4 is your new IP address whereas yourdomain.com is the domain name of your Magento store. Once the testing is done, delete this line from the host file.
After this, reload your website and check if everything is going correctly. Inform your users about the change your website has gone through. This is an important step of the whole migration process.
Sync your data
If everything goes well as per the expectations, you can now proceed to sync your data. This is a crucial step, so make sure you keep the following points in your mind while going about it.
- It’s not possible to update DNS settings on a frequent basis, so it is recommended to modify your domain TTL time to reduce the time. Also, make sure you don’t rush into the final stage of migration without waiting for the expiration of old TTL time.
- Keep your store server turned off while syncing the data
You can turn off your old server by enabling cron and then maintenance mode at touch /home/mageold/public_html/maintenance.flag.
Now, sync your data this way:
rsync -avz --delete -exclude=var/cache --exclude=var/full_page_cache --exclude=var/log --exclude=var/report --exclude=var/session --exclude=app/etc/local.xml /home/mageold/public_html/ magenew@newhost:/home/magenew/public_html/
mysqldump --add-drop-table -h localhost -u mageold_magento -p mageold_magento | gzip > ~/magento-db.sql.gz
scp ~/magento-db.sql.gz magenew@newhost:
You can now start uploading the database to the new server.
gzip -dc ~/magento-db.sql.gz | mysql -h localhost -u magenew_magento -p magenew_magento
There are chances that your access permissions get changed at the time of synchronization. So, make sure they are restored.
You can now clear the Magento cache this way:
rm -fr /home/magenew/public_html/var/{cache,full_page_cache,log,report,session}
The Final Step
In the final step, just turn on the cron task for the newly migrated server and modify the DNS settings. As soon as the TLL time expires, you can direct the traffic on the new server.
All said and done. These are some important steps that need to be taken while migrating your Magento store to a brand new server. You can bookmark this page, so that you can remember them.
Author Bio: Claudia Jhonson is a web developer at Magentax an Offshore Magento development company that has been remarkable in delivering high-quality Magento Ecommerce development service. You can go through her articles which are based on tips and tricks for handling Magento development projects.
You must be logged in to post a comment.