10 Steps to Host WordPress Website from Localhost to Server

Provide your ratings to help us improve more

Finding the right way to host WordPress website on localhost requires a bit of time and attention. Here are the steps to move my WordPress site from localhost to cPanel or move your site from local XAMPP to the web server. It would even if the host uses alternatives like their own control panel and Plesk!

What are the local development tools for Linux, Mac, and Windows?

  • Local
  • DevKinsta
  • Lando
  • XAMPP

Local Development Tools for Mac and Windows

Before you get down to how to move a WordPress Site form Localhost to live server, see the tools required!

  • Server Press

Local Development Tools for Windows

Laragon

Steps Involved in Hosting WordPress Website from Localhost to Live Server?

Local Site Backup

When using the manual method for migration of a website from localhost to a live server, there is a possibility of error as numerous tools are involved. Therefore, to safeguard your websites you need to make a backup before instigating the migration process. Also, make a backup of every successful step to avoid doing work from scratch in case of any problem!

Copying Files from Localhost to the Live Server

Login into the Server

By using your SFTP client of choice and providing SFTOP credentials,  you need to log into the web server.
Note: In case you get “Host Key Unknown” Error, it is not a problem. Most SFTP clients who use  TOFU authentication face this problem. Click on “OK” and proceed. If you will log into the website via SFTP again, it is better to check “Always Trust This Host and This Key To cache”. 

Look for Website Files on Local Computer

In most cases, you will find the server files in the right pane and the local files in the left.
Your local host ensures your access to the WordPress site files. Consider yourself in the right place when you see the “Wp-config.php” file alongside directories such as we-content.

Navigation of Public Directory on your Web Server

You would generally find a folder labeled as “www” or “public-html”. Always check with the host if unsure.  Also, in case, the files in the subfolder, you would have to navigate to the subfolder!
From the left pane, select all the local files, and drag them to the right pane.

Importing Data from Local Database to Live Database

Connect to the database to view the live site. If you face the error “ error establishing a database connection” while navigating to the public URL from the browser, it means the following

  • WordPress files successfully uploaded
  • The site lacks a database connection
  • Exporting database from Localhost

The database is an imperative part of your WordPress installation as it stores all the data — settings, post content, etc.
phpMyAdmin is part of almost all local development environments and a safe way to export databases. Adminer is a less popular alternative.

In phpMyAdmin

  1. Choose Data base
  2. Click on “Export” tab
  3. Select Quick>SQL > Go.

In Adminer

  1. Choose Database
  2. Click on Export from menu
  3. Choose SQL for output, and click export.

An SQL file will be downloaded onto your system!

Creating a Database on a Live Server

Create a blank database on the web server by following the steps below.

  1. In the hosting control panel go to Databases> MySQL Databases
  2. From “MYSQL Users” create a new user.
  3. Go to “Add user to database > newly created user and database > add

Edit Wp-Config.php file

The wp-Config.php file contains important database-related information. WordPress uses this file for database connection, retrieval of data, and storing critical information including users, post meta, etc.

  1. Open localhost, copy the wp-config.php file, then open the file in a text editor.
  2. Head to MySQL section of the config file, and replace database details with the ones you created.

Note: Some website move to the liver server, but they still have DH_HOST as the local host. So, check that! 

Use drag and drop to save and overwrite the files uploaded to the web server via your SFTP client.

  • Important Data
  • Go to phpMyAdmin>cPanel> Databases
  • Select newly created database and click Import tab.
  • Select Choose File> exported SQL file.
  • Click Go.
  • Change URLs site in DataBase
  • Launch phpMyAdmin > Database
  • Under the option_name column, look for siteurl and home .
  • Double click option value under option values column, and change both to your new URL. Don’t include “/“ at the end.
  • Open browser, type the live site url with /wp-admin. Now you can see your WordPress dashing board.

Flush your Permalinks

  • Head to WordPress Dashboard and log in
  • Go to Settings> Permalinks
  • Select “Save Changes”
  • Search and Replace LocalHost URLs

To replace localhost urls in your database, here is what you need to do.

  • Use an SQL query
  • Use plugin

We will work on the Plugin Method

  1. WordPress Dashboard > Plugin > Add New
  2. Look for Better Research Replace > Install Now > Activate
  3. Now to go WordPress Dashboard > Tools > Better Research Replace
  4. Fill “Search for” filed with localhost URL
  5. Fill “Replace with” filed with web server URL
  6. Choose the database tables on which you want to perform the replace/search query. Usually, this step is important only for wp-postmeta and wp-posts tables.
  7. Replace GUIDs unchecked and keep it “Case-Insensitive”
  8. Check Run as Dry Run?.
  9. Now select Run Run/Replace.
  10. Look out for changes, you will see numerous change at this point. If that is not the case, you need to double-check your URLS. In case, your URLs are correct, and nothing is changing, you don’t have to proceed, delete the plugin.
  11. If you still need changes, uncheck the Run as dry run option and then select the Run/Replace option.
  12. Next, deactivate and uninstall the better search reach. Now see of the site is working fine, then delete the plug in, you have done with moving WordPress from localhost to server.

Comments are closed.