How to Upload a Local WordPress Site

local wordpress site

Last year, I offered up a tutorial for creating a local WordPress site using Xampp for Windows. I also gave you pointers on how to create a local copy of a live WordPress site. Ever since those posts were published, I’ve received multiple requests for a tutorial on what to do once you’re done tinkering locally and wish to upload your site to an online server.

You have a couple of main options. You can use a plugin to turn your local site into a package to be uploaded to your hosting server. There are actually some great tutorials online already about how to make the most of such plugins. Here are a few I’ve come across:

But if you don’t want to use a plugin, the uploading process isn’t that complicated and can be accomplished within a relatively short period of time. All of your settings, themes, posts, pages, and plugins will be uploaded in the right place, intact.

Let’s get to it!

1. Get Familiar with phpMyAdmin

The first step is to familiarize yourself with phpMyAdmin. Why? Because WordPress runs on PHP. It actually uses PHP to call up information from a database.

You’re not making new HTML pages when you make new posts in WordPress. Rather, WordPress is using PHP to reference the database and dynamically generate your posts and pages on the spot. And while you don’t need to be an expert in this programming language, you do need a basic level of knowledge to upload a WordPress site from a local server to your hosting account.

phpMyAdmin is a piece of open source software that puts an easy-to-use UI on top of your MySQL database. The good news here is that most hosting providers include phpMyAdmin in cPanel, so it is on hand in a convenient place. For more information on this piece of software and how to use it, check out this tutorial over at WPBeginner.

2. Backup Your Database

Before you do anything, it’s essential that you backup your database. This way, in case you make a mistake when trying to upload the local version of your site to a live server, you will have something to fall back on.

export-local-wordpress

To backup your database, select your local WordPress database within the phpMyAdmin list then click Export.

export method-local-wordpress

Select Custom then zip as your compression method.

zip-local-wordpress

Then click Go. That’s all there is to it.

3. Export Your Database From localhost

Now you’re going to do pretty much the same thing as in the previous step with just a couple of slight variations.

In phpMyAdmin, select your local WordPress database once again and click Export. Click on Custom when prompted for your preferred Export Method. This time, you’re going to select all tables to export and gzipped rather than zip.

gzipped-local-wordpress

Click Go. This will create a copy of your database. This is the version you’ll upload to your live site.

4. Upload Your Database Using FTP

The next thing you’re going to do is actually upload your WordPress files to your hosting account. To do this, you’ll need an FTP client. If your face has gone pale and you have no idea what I’m talking about, check out this tutorial at WordPress.org for FileZilla (my FTP client of choice). It explains all the basics quite nicely.

Once you have a handle on how to use an FTP client, launch your preferred one and connect to your live hosting account. Next, find the directory where you’d like your site to appear.

Typically, you want a site to appear at yoursitename.com. To make sure this happens, select the public_html directory. Then locate the files for your local WordPress site (everything in the WordPress folder when you originally downloaded it), select them all and upload them to the appropriate directory.

5. Create a MySQL Database

Congratulations! Your files are now where they need to be in order for your WordPress site to be visible to the public. However, your job isn’t done yet. You now need to create a MySQL database on your live site.

Doing this will ensure your site appears as you intended and all of your posts, pages, and settings load as they should. Go into the cPanel on your hosting provider. From there, scroll down to the Databases subheading. There you should find an option for MySQL Databases, which looks like this:

upload local wordpress

Click on it. Once you’re on the Create New Database screen, input a name for your database. Then click the Create Database button.

create-new-database

Next, locate the MySQL Users section. Create a new user. You will need to create a username and password.

create-new-user-database

Then add that user (or an existing user) to the database.

add-user-database

Finally, set the new user’s MySQL privileges. In order for this to work properly, the new user should be granted all privileges.

mysql-user-all-privileges

6. Import Your WordPress Files

Now that you have your database created, you need to import the files you uploaded earlier into this database. Prior to this step, your WordPress files were just kind of hanging out, waiting to be deployed. This is where you fire them into action!

Go back into your cPanel and click on phpMyAdmin. Next, select the MySQL database you created in the previous step. You’ll notice that it doesn’t have any tables. This is where you want to plug in your WordPress info. To do this, click on Import.

import-wordpress-database

A file selection window will pop up. Find the gzipped file you created earlier and upload it by clicking Go.

import-database-file

7. Fixing the URL

You’re getting closer to the end — now you just need to switch some settings so your WordPress site realizes it has a new home.

Basically, at this point it time, it will still have configuration settings that match your localhost. You need to fix that. Thankfully, it’s pretty simple. While still in phpMyAdmin, scroll down to the wp_options table. There should be a Browse button to the right of it. Click this.

phpmyadmin-wpoptions

Once on the next screen, you should see a field called option_name. Beneath that, there should be something called siteurl. Click the Edit link to the lefthand side of this row.

Once the edit window opens, look for the option_value field. It should be to the right of siteurl. It likely currently says something like http://localhost/blahblah. Get rid of this and type or paste in your live site URL.

database-siteurl

Click Go to save your changes.

Now, look for the home option underneath the option_name column. Click Edit and input your live site URL under the option_value.

database-home

Click Go to save your changes. You can now close out of phpMyAdmin.

8. Finishing Setup

Now you need to open up your FTP client and edit your wp-config.php file. Remember the MySQL database you made earlier? I hope you kept that info on hand because you’ll need it now.

Input your database name, username, and password on the appropriate lines — here’s a quick rundown of how to do it — then save the file and re-upload it onto your live server.

When you type in your website address in your browser now, your WordPress site should appear. And that’s pretty much it! If you find broken links or image pathways, WPBeginner has a nice tutorial of how to deal with that. Other than that, you’re good to go.

Conclusion

Many web masters find building a WordPress site on a local server to be advantageous. It allows for the freedom to experiment without the risk of potential Google caching. Still, the task of uploading the site and changing all of the required settings can be daunting to some. Hopefully this tutorial helped to waylay your fears a bit so you can make the most of your offline WordPress development efforts.

Over to you. What has your experience been with uploading a local site to a live server? Did you run into any problems? Or was it a breeze? I’d love to hear your WordPress migration story.

Image source: screenpunk

Tom Ewer

Tom Ewer is the founder of WordCandy.co. He has been a huge fan of WordPress since he first laid eyes on it, and has been writing educational and informative content for WordPress users since 2011. When he's not working, you're likely to find him outdoors somewhere – as far away from a screen as possible!

9 Comments

  1. martin

    So has anyone actually got any constructive advice on what the fuck i’m doing then? I’m still getting “Error establishing a database connection”

    I have WP locally installed,
    I have an FTP client,
    I have a domain name,
    I have usernames and password for ftp’s, php’ and sql’s & domain registration companies,
    I have a website ready to be uploaded,
    I have now unsuccessfully fucked around with username’s, tables, zipping databases up and down, both php/sql control panels and other shit i have no comprehension of, for over 3 days straight now (no joke).

    CAN ANYONE ACTUALLY TELL ME WHAT NEEDS DOING SO PEOPLE CAN VIEW MY WEBSITE?????

  2. Maurice

    Sorry? What? I have a website, I have to do something with PHP, then I have to do the same again, but different. I have to export something twice and then import the same thing again. Then something about databases…. If you make an article for experts, don’t state it is easy. It is not! WP is not for beginners. Same as their “famous 5 minute installation”. Bull shit, it took me over 4 hours and I still have no idea what to do next… I.m.h.o., WP is the biggest scam on the web.

  3. tushar grover

    your wordpress tutorial really rocked
    i came to know many great and useful things about wordpress
    thanks for writing

  4. Tom Ewer

    Author

    Thanks for the feedback guys (not including the wild accusations of stealing content). I’m going to go through it all with a fine tooth comb, improve the tutorial and will get back to you 🙂

  5. Editor

    You need to seriously STOP taking (stealing) content from other peoples sites and republishing it on these sites that pay you to do it.

    Your tutorial is seriously flawed because you simply haven’t tested the solution or gone thru the process.

    1.I would use WP Migrate DB before exporting a copy of the database locally as it enables you to easily change the server path and domain.

    2. You don’t import your files into php My Admin. You import one file which is your database.

    3. You don’t upload your database using FTP. You import it using phpMy Admin.

    4. You didn’t mention anything about the wp-config.php file and changing the database connection details.

    You may get away with this because you’re in the U.K but if you where in my country, they would be extremely harsh on you.

  6. Thomas

    Rather than change paths in wp_options, I like to add an entry to my hosts file so that I can install the site locally as if it were on the live domain. This requires editing some system files, so it might not be for everyone. For example, if your domain is domain.com, you’d add:

    127.0.0.1 domain.com

    to hosts file (/etc/hosts on Mac)

    Then you don’t need to mess with the database at all, or worry about any paths in wp_posts that reference localhost.

    1. Dan Knauss

      If you set domain.com as your local development version in your hosts, then you run the risk of forgetting that’s not really the live site, which you’d have to view from a separate machine. That is why ServerPress uses .dev instead of your actual TLD. I’d recommend ServerPress a great tool for setting up and managing local development versions of WP sites.

  7. Mikhail Levin

    Well, it’s misleading. Steps ## 6 and 7 must be reverted – with all the changes done to the SQL file before it gets uploaded. Changes done to both domain name and the folder name locations. And do not forget the serialized data.

    Not mentioning – before the move, try to make the database as small as possible, for example, remove all previous revisions.

    So, this article is not really complete and still misleading.

    1. Dan Knauss

      Mikhail is right. You need to use a tool like WP Migrate DB to properly change all URLs to the destination site as you export your database. (Tom McFarlin has blogged the steps for doing this and has a 3-part tuts+ series of articls about it.)

      There is also a mistake in the heading for Step #4 which is not really about uploading the database to the server. This step only describes uploading WordPress files by FTP.

      Another problem is that the people who would be most likely to follow this advice will be using low-end hosting where there is usually a limit as low as 20MB on SQL files you can import through phpMyadmin. (The screenshot shown above displays a 50MB limit.) There are ways around this, but they add more steps and complexity.

      Better advice would be to:

      1) Develop in a staging area on the same server as the production site, possibly using a staging tool offered by some hosts.

      2) Use a staging, migration or backup/restore plugin to clone sites from localhost to staging or production and vice versa. There are a variety of different options in the plugin repository.

      3) Learn to do the whole process quickly from the command line, or just the steps necessary to quickly move your files and database to the live server.

Leave a Reply

Your email address will not be published. Required fields are marked *

Over 65,000 WordPress professionals are already using ManageWP

Add as many websites as you want for free, no credit card required. Sign up and start saving time!

Have questions? Get in touch!

Over 65,000 WordPress professionals are already using ManageWP

Add as many websites as you want for free, no credit card required. Sign up and start saving time!



Have questions? Get in touch!

Over 65,000 WordPress professionals are already using ManageWP

Add as many websites as you want for free, no credit card required. Sign up and start saving time!



Have questions? Get in touch!

Over 65,000 WordPress professionals are already using ManageWP

Add as many websites as you want for free, no credit card required. Sign up and start saving time!



Have questions? Get in touch!