Backups and migrations

Move a locally developed WordPress site to your hosting

Reviewed on 6 min read WordPress migrations

It's common to build a website on your computer (with XAMPP, MAMP, Local, Laragon…) and, once it's finished, get it running on the hosting. The process is simple if you bear in mind that the website has two parts: the files and the database. You need to upload both and then tell WordPress where the new database is and what its final domain is.

If the website isn't on your computer but on another hosting, you're better off following the guide to migrate WordPress to another hosting.

1. Upload the files

If the website is the account's main domain, the files go in the public_html folder. If it's an addon domain, upload them to the folder assigned to that domain (you can see it in cPanel > Domains).

There are two ways to upload them:

2. Create the database

Create the database and its user with cPanel's MySQL Database Wizard. Note down the database name, the user and the password, and in the privileges step tick ALL PRIVILEGES.

Note that cPanel adds your account name in front: if you create the database wp, its full name will be something like tucuenta_wp. That full name is the one you need.

3. Export and import the database

Almost all local environments come with phpMyAdmin, the same tool you have in cPanel. In the phpMyAdmin on your computer, select the WordPress database, open Export and download the file with the default options. You'll get a .sql or .sql.gz file.

Then, in cPanel > phpMyAdmin, select the database you created in the left-hand column, open the Import tab, choose the file and click Import (at the bottom of the page) with the default options:

phpMyAdmin Import tab with the file selector for uploading the .sql file

When it finishes, you should see a message saying the import was successful and the list of WordPress tables (wp_posts, wp_options…).

4. Edit wp-config.php

Now WordPress needs to connect to the new database. Open the wp-config.php file in public_html: you can edit it on your computer and upload it again over FTP, or edit it directly from cPanel's File Manager (right-click > Edit):

Editing the wp-config.php file from cPanel's File Manager

Change these values to those of the database you created:

DB_NAME, DB_USER and DB_PASSWORD values in wp-config.php

  • DB_NAME: the full database name (with your account prefix).
  • DB_USER: the full user name.
  • DB_PASSWORD: its password.
  • DB_HOST: leave it as localhost.

Don't change $table_prefix: it must stay the same as the one you used locally.

Just below the line define('WP_DEBUG', false); add these two lines with your final domain, so WordPress stops using the local address:

define('WP_HOME','https://nuevodominio.com');
define('WP_SITEURL','https://nuevodominio.com');

WP_HOME and WP_SITEURL lines added to wp-config.php below WP_DEBUG

Save the file. The website should now load on your domain.

The lines above change the main address, but the content (images, internal links, settings of page builders such as Elementor) still stores the local URL, for example http://localhost/miweb. You need to replace it in the database.

Don't do it with find and replace in the .sql file: WordPress stores a lot of serialised data and a direct text change breaks it. Use one of these options:

  • With a plugin: install Better Search Replace, go to Tools > Better Search Replace, enter the local URL in Search for and the final one in Replace with, select all the tables and run it first with the dry run box ticked. If the result is what you expected, untick it and run it for real.
  • Over SSH with WP-CLI, from the WordPress folder:
wp search-replace 'http://localhost/miweb' 'https://nuevodominio.com' --all-tables --dry-run
wp search-replace 'http://localhost/miweb' 'https://nuevodominio.com' --all-tables

The first command only shows how many changes it would make; the second applies them.

When you've finished, go to Settings > Permalinks and click Save Changes to regenerate the .htaccess rules.

Before you consider the website live

  • In Settings > Reading, untick Discourage search engines from indexing this site if you turned it on during development.
  • Browse several pages and check that the images load from the new domain.
  • Test the forms and email sending.
  • If the domain still points to another server, you can view the website on the hosting before changing the DNS.

You may also find useful

Something wrong or out of date? Tell us and we will review it.