How to Properly Migrate Magento to a New Server

magento2migration

I could not make Magento 2 work on a new server by copying the backup and DB and installing all required software. No links working for me from the homepage, as if something wrong with rewriting, and I could not find why yet. I made a new install in another directory and it is working.

What is proper procedure of migration of Magento setup to another server?

Best Answer

Without any further details, I try to guess: Are your base URLs of the magento installation correct?

You could use the following commands to get the current values:

SELECT * FROM core_config_data WHERE `path` LIKE '%web/unsecure/base_url%';
SELECT * FROM core_config_data WHERE `path` LIKE '%web/secure/base_url%';

If not, you have to adjust them either directly within the database or via the console according to the official documentation on store cli commands (--base-url & --base-url-secure).


General migration procedure

After loading the database dump and extracting your backup, you have to set the correct database credentials in app/etc/env.php within the installation directory.

Then, you should check the database for the following two values in core_config_data table:

  • web/unsecure/base_url
  • web/secure/base_url

Update the filesystem ownership and permissions: Please refer to the official tutorial on filesystem ownership and the official tutorial on permissions on production and development mode.

If you want to run this installation in production, run the magento deploy:mode production command (as magento user/magento file system owner) to delete and regenerate caches, etc. Otherwise clear them.

Last but not least: Check the Cronjobs (if you used them on your old machine.

Please refer to Khoa TruongDinh's answer to a similar question for further details.

Related Topic