How to Move Magento 2 from Localhost to Server

Magento 2 store setup can be complicated. You may not want to offer a half baked setup to your potential customers only to disappoint them.

The solution is to first set up the Magento 2 store in localhost. You may have spent hours building your store. Once you finish implementing and configuring every feature, you can go LIVE!

This post shows the method to move Magento 2 from localhost to server.

Steps to Move Magento 2 from Localhost to Server:

Step 1: Export Database from Localhost

  1. Connect to localhost software like XAMPP, WAMP etc and login to phpMyAdmin
  2. Visit the store’s database
  3. At the top of the menu, click Export then hit Go button.

How to Move Magento 2 from Localhost to Server 1

Now, you will be able to download the database files as the .sql extension. You can also save it in .zip form.

Step 2: Make Magento Files in Zip Format

Select all the files and folders from localhost and make a zip file.

  1. Go to htdocs folder (if you are using XAMPP) or www folder (if WAMPP)
  2. Navigate to Magento folder and compress the files in zip format

Step 3: Uploading Magento Files to Web Server

For uploading database, you need to upload via cPanel that is your website server. But before that, you need to create a user and give database rights.

  1. Login to cPanel.
  2. Go to phpMyAdmin
  3. In phpMyAdmin, create a new database by clicking on the new button. Make sure you remember database name, username and password.

Step 4: Import Database

After creating a database, you need to import the database file which you have downloaded in step 1.

You can leverage two methods for importing the database.

The first method for importing the database is by using the command line.

The second method for importing the database is by using PHPMYADMIN.

  1. Find out the Import option at the top of the menu and click on it
  2. To import the database, hit Choose File and upload a file having .sql extension

How to Move Magento 2 from Localhost to Server 2

Make sure to select the correct character set to avoid the unknown collation error in MySQL during the import process.

Step 5: Upload Magento Files

You can also create a subfolder for a new domain. If you do not wish to do, you can continue with normal directory also.

Upload the zip file and extract that you created in step 3.

Step 6: Change env.php file for Accessing the Magento System to New Database

Once you finish uploading the zip folder with extraction, you will now need to make changes in env.php file.

Go to app/etc/env.php. In env.php file, you will have to make changes related to the information of the new database that you just created on your domain. Make changes in a username, name and password while importing the database to your new domain. Locate in the file where this information is suitable. You will find something like the below image.

Step 7: Find Out your New Domain Name for Magento System

After the completion of step 6, you need to make save the changes.

  1. Click Save in the top right
  2. If you wish to select and edit the file, you need to upload it again to the right directory. For that, go to the Magento database and search Table Core_Config_Data.
  3. Replace localhost URL to domain name in “web/unsecure/base_url”

How to Move Magento 2 from Localhost to Server 3

Step 8: Run Below Commands

Run all the below commands and you will manage to access your Magento store.

That’s it.

U kunt commentaar op deze vraag geven

Beoordeel deze vraag:

0 (0 Stemmen)