DEV Community

Cover image for How to Move Magento 2 from Localhost to Server

How to Move Magento 2 from Localhost to Server

webgurudev on May 26, 2023

If you're looking to make your online store accessible to the public, it's crucial to know the steps involved in transferring Magento 2 from localh...
Collapse
 
ibtisam021 profile image
Ibtisam021 • Edited

The main keypoints that one should fololw in order to move magento 2 from localhost to server are as follow:

Backup the Local Magento 2 Files and Database: Before transferring the website, create a backup of all the Magento 2 files and the database from the localhost environment.

Choose a reliable Managed Magento Hosting: A reliable managed Magento hosting helps in optimizing performance of your Magento website.

Upload Files to the Live Server: Upload the Magento 2 files to the root directory of the live server using FTP or cPanel File Manager.

Create a New Database on the Live Server: Set up a new database on the live server and import the backed-up database from the localhost.

Update Configuration Files: Modify the configuration files "app/etc/env.php" and "pub/index.php" with the live server's database and base URL details.

Update URL Rewrites: Clear the URL rewrites in the live server database and update them using the following command: "php bin/magento setup:static-content:deploy".

Change File Permissions: Set appropriate file permissions for Magento 2 files on the live server using SSH.

Flush Caches: Clear the Magento 2 cache to ensure smooth functioning on the live server.

Test the Website on the Live Server: Visit the website on the live server and test its functionality to ensure everything is working correctly.

By following these steps, users can successfully migrate their Magento 2 website from localhost to a live server, making it accessible to the public and ready for production use.