Move a local WordPress site to online hosting

Migrating a local WordPress site to online hosting

To put a WordPress site built on your computer online, the simplest way is a migration plugin such as Duplicator or All-in-One WP Migration: it packs up the files and the database, then replaces the site addresses on arrival. The manual method, with an FTP client and phpMyAdmin, is still useful to understand what is going on and for large sites. Here are both.

In short

  • A WordPress site is files plus a database: you need to move both.
  • Simple method: Duplicator or All-in-One WP Migration, which also replace the addresses.
  • Manual method: FTP transfer, database export and import, editing wp-config.php, replacing the addresses.
  • Never replace the addresses with a plain SQL query: some data would be damaged.
  • After the migration: permalinks saved, installer files deleted, HTTPS checked.

This guide applies to a site built locally with MAMP, Local or WAMP, and adapts to a move from one host to another, or from the live site to your computer.

Before you start

  • a file transfer client, such as FileZilla, and your FTP or SFTP access (in your host’s customer area);
  • an empty database with your host, with its name, user, password and server address;
  • the empty destination folder on the hosting (often www or public_html);
  • a backup of your local site, just in case.

Method 1: with a plugin

Duplicator

  1. On your local site, install Duplicator from Plugins > Add New Plugin.
  2. In the Duplicator menu, create a backup. The plugin scans the site, then produces an archive and an installer file (installer.php).
  3. Download these two files, then upload them by FTP to the destination folder on your hosting.
  4. Open https://your-site.com/installer.php in your browser.
  5. Enter the database details, test the connection, then run the installation. Duplicator replaces the old address with the new one.
  6. Log in to the site, then delete the installer files when Duplicator offers to. Never leave installer.php on a live site.

All-in-One WP Migration

Another very popular option: install All-in-One WP Migration on your local site and export the site to a file. Then install a fresh WordPress with your host, add the plugin to it and import the file. The addresses are replaced automatically.

One limit: in the free version, the size of the imported file depends on what your host allows. For a large site, a paid add-on from the same publisher removes this limit.

Method 2: by hand

1. Transfer the files

Connect to your hosting with FileZilla (host, username and password, provided by your host). Open the destination folder, then drag in all the files of your local WordPress: with MAMP, they are in the htdocs folder. The transfer is finished when the FileZilla queue is empty.

2. Transfer the database

  1. Open phpMyAdmin locally (with MAMP, from the MAMP start page).
  2. Select your site’s database, then the Export tab, Quick method, SQL format. Save the file.
  3. Open your host’s phpMyAdmin, select the empty database, then the Import tab, choose your file and run it. A green message confirms the import.

3. Edit wp-config.php

On the hosting, open the wp-config.php file at the root of the site and replace the local values with those of your host:

define( 'DB_NAME', 'database_name' );
define( 'DB_USER', 'database_user' );
define( 'DB_PASSWORD', 'password' );
define( 'DB_HOST', 'database_server_address' );

If the table prefix ($table_prefix) is not wp_, keep the one from your local site.

4. Replace the site addresses

Your database still holds the local address everywhere: in the settings, the content and the plugin data. The previous version of this guide suggested an SQL replace query. Do not do that any more: part of the WordPress data is stored in a so-called “serialized” form, which includes the length of each string. A raw replacement breaks this data, and settings disappear.

Use a tool that knows how to handle this data:

  • WP-CLI, if your host gives SSH access. Run a dry run first, then the real replacement:
wp search-replace 'http://mysite.local' 'https://www.my-site.com' --all-tables --dry-run
wp search-replace 'http://mysite.local' 'https://www.my-site.com' --all-tables
  • The Better Search Replace plugin, with no command line. If you cannot log in to the site because it redirects to the local address, first fix the two settings home and siteurl in the wp_options table with phpMyAdmin, then run the plugin.

No trailing slash at the end of the addresses, and watch the https: replace with the exact address of the live site.

After the migration, whichever method

  1. Save the permalinks: Settings > Permalinks, Save Changes button, without changing anything. This prevents 404 error pages.
  2. Check HTTPS: activate the SSL certificate with your host, and check that the site address starts with https in Settings > General.
  3. Site built with Elementor? Run Elementor > Tools > Replace URL with the old and the new address, then regenerate the CSS files from the General tab of the tools. Elementor stores some addresses in files that migration tools do not always see.
  4. Clear the caches: cache plugin, host cache, browser.
  5. Go round the site: pages, images, forms, admin login.

Shall we take care of it?

Going live, changing host, switching to HTTPS: we have been migrating WordPress sites since 2010. And if you are looking for somewhere to host yours, our WordPress hosting is designed for this kind of site.

Let’s talk about your site

Contents
Read next

More articles that may help you

Illustration au trait : un casque audio, une onde sonore, un stockage de fichiers et le symbole d’un flux RSS

Self-hosted podcast: moving a podcast to WordPress and Cloudflare R2

Read the article →
Illustration au trait : une patinoire vue de dessus, des sapins et un écran d’état avec deux pastilles

Ice rink and skating trail: a municipality’s custom WordPress plugin

Read the article →
WooCommerce e-invoicing: how to make your shop compliant

WooCommerce e-invoicing: how to bring your shop into compliance

Read the article →

A project, a question?

Free quote · Refundable deposit · Balance only if satisfied · No commitment