How to Take Your Local WordPress Site Live
Today, I’ll share how to move WordPress from localhost to a live server so you can launch your website with ease.
Before You Begin
Prior to starting the process of moving WordPress from localhost to server, there are a few things you need:
- A WordPress site on a local development server with full access to it.
- A domain and hosting package where you can upload your website.
- An FTP (File Transfer Protocol) client.
How to Move WordPress from Localhost to Server
To manually move WordPress from localhost to server you will:
- Transfer the WordPress database and files.
- Make sure all WordPress URLs and media links are updated.
Below is a breakdown of these steps in detail.
Export Database from Your Local Server
The database of your WordPress site houses all your users, posts and taxonomies which are all must-keeps if you have input content on your site already.
To move the database, open your local server application’s phpMyAdmin and select the database you want to export in the left-hand sidebar.
Select the Export tab from the navigation bar at the top of the screen.
The two export methods are Quick, which displays minimal export options, and Custom, which displays all the export options.
We recommend choosing Quick. Then, click Go.
Upload Files to the Live Server
While your database has all of your post content, your files contain your themes, plugins and core WordPress files.
To move your files from your local server to a web server, use an FTP client to connect to your remote hosting server.
Every web host’s setup is different so most hosting companies provide tutorials on uploading files to their servers using an FTP client. If you get stuck, check your web host’s support area for further instructions.
Make sure your FTP client is connected to the correct folder on both your local computer and remote web host. The latter is typically the public_html folder, but could be a subdirectory within public_html depending on how you have configured your server space.
Check with your host if you unsure what folder you should use on your server.
Then, upload all of your local WordPress files to the live server.
Create a Database on the Live Server
Most hosts use cPanel to manage their databases. If your host uses something else, check with them for details on creating a database.
Log in to your hosting account’s cPanel dashboard and go to the Database section.
Select the MySQL Databases icon.
Next, enter a name for your database in the Create a New Database > New Database field.
Click the Create Database button.
Now, you can either create a new user and add it to the database or add an existing user to the database.
After doing so, you’ll be asked to select what privileges this user can have. In this case, all privileges should be granted.
Check All Privileges and click the Make Changes button.
Import Database to Live Server
Back in the cPanel dashboard, go to the Database section again and this time click on phpMyAdmin.
Select the Import tab at the top of the screen.
Click the Choose File button, then locate and pick the local database file you created earlier.
Click Go at the bottom of the page. PhpMyAdmin will now upload your database.
Change Your Site URL
If the actual website address doesn’t match the site URL in the database, WordPress won’t function properly.
The URL of your local WordPress site was probably something like this: http://localhost/wp-site-folder. However, the live WordPress site will be using your purchased domain URL which would look something like this: https://www.my-wp-site.com.
You can change the site URL in your newly imported database by updating the database tables.
In phpMyAdmin, select your database from the sidebar on the left and go to the Structure tab.
In the tables that appear, locate the wp_options table and select Browse.
In the Browse tab, you should see another table that houses the Options data. The options you’ll need to edit are siteurl and home.
The siteurl is the domain address your website uses and home is the address visitors are redirected to when they click a home link on your WordPress website.
Select Edit for siteurl.
On the next page, update the option_value field to be the live website URL. Then, click Go to save your changes.
Repeat these steps for the home option. Typically, you should use the same URL for both.
Now that all your database and files are in place, you can set up WordPress.
If you visit your live URL at this stage, your site will display an error regarding your database connection because your wp-config.php file isn’t using the new database credentials.
To solve this error, connect to your live website with the FTP client and open your wp-config.php file.
Replace the database name, username and password credentials with the ones you created in the cPanel earlier.
For the hostname, you can leave it as localhost or replace it with the server IP address.
It may be important to note that you should make a copy of your old values in case you need to revert back to them for any reason.
Save the wp-config.php file and upload it back to the server. Check your live website again and the error should be gone.
To ensure that the site URL is corrected where ever it’s necessary, log into your WordPress dashboard and go to Settings > General.
Without changing anything, scroll to the bottom of the page and click Save.
Lastly, go to Settings > Permalinks and click Save Changes to integrate the URL changes with the rest of WordPress.
Fix Images and Broken Links
Often when you’re trying to move WordPress from localhost to server, links and images can end up broken or missing.
This simple SQL query can help you solve the issue when it’s run in your web server’s phpMyAdmin:
UPDATE wp_posts SET post_content = REPLACE(post_content, 'localhost/test/', 'www.yourlivesite.com/');
To run the query, access phpMyAdmin from your cPanel, select your WordPress database and go to the SQL tab at the top of the page.
Paste the query, update the URLs to match your setup, then click Go.
Shifting into Automatic
If you don’t love the manual nature of the process to move WordPress from localhost to server, here are a couple plugins that will free up your time and any possible headaches.
All-in-One WP Migration is an extremely popular plugin with over 1 million installations and counting. The plugin help with transferring WordPress websites from one point to another with no need for any sort of technical knowledge.
The plugin is compatible with all PHP hosting providers, has unlimited find and replace operation in the export process, and can easily bypass hosting file size restrictions.
Duplicator is a migration plugin that gives WordPress users the ability to migrate, copy, move or clone a site from one location to another.
It also serves as a simple backup plugin. Duplicator creates packages that bundle together all your WordPress files and database into ZIP format for easy transportation.
With this particular plugin, it helps to have some technical knowledge and understanding of the migration process.
Taking a site live is an exciting culmination of all your hard work. While it may initially feel complicated to move WordPress from localhost to server, the steps above should help make the process a snap.
Do you prefer to manually move WordPress from localhost to server or do you prefer using a plugin? Were you able to successfully migrate your site? Did you run into any issues during the migration process? Let us know in the comments below.