Follow me on social media:

13 Steps To Deploy WordPress From Your Localhost To A Live Web Server

I love using WordPress, but there’s one process that really annoys the heck out of me when I’m developing websites with it and that’s deployment from a localhost server to a live web server. There’s no set way to do this, but this guide attempts to solve that problem. This is the method I’ve found most reliable when deploying websites from localhost to a web server.

Tools Used In This Guide

Steps to Deploy WordPress From Localhost To Your Web Server

  1. Export your DB from the localhost using phpMyAdmin as a .zip
  2. Extract the zip locally somewhere for editing
  3. Open the .sql file in jEdit (or equivalent UTF-8 capable editor) and do a string search for localhost
  4. Find the string you need to replace, usually http://localhost/your-site depending on how you’ve setup your local server.
  5. Do a global string replace using the replacement string you found and replace it with your new domain, something like http://your-domain.com
  6. Save in UTF-8 format. You might want to save as a new file just in case you need to revert.
  7. Using phpMyAdmin on your destination web server create a database and import the new .sql file. With some cPanel hosts like Bluehost it’s easier to create using cPanel’s tools then edit in phpMyAdmin for importing the file. If all is okay you should now have your database setup.
  8. Using FileZilla (or equivalent FTP program) upload your website’s files to the web server.
  9. While the upload is happening, it’s time to create the wp-config.php file for your production instance, make a copy of the existing wp-config.php file in your WP root directory.
  10. Open and change the database value to the name of your web server’s database for your site. Also, change the username and password for the database as required.
  11. Save this as wp-config.production.php and upload to your web server.
  12. Once all uploading is complete, using FileZilla rename the existing wp-config.php file on your web server to wp-config.development.php and also rename wp-config.production.php to wp-config.php. Your new config file is now in effect.
  13. Before you get all happy and try to visit your website you need to login to the WordPress admin and navigate to the Permalink settings. Once there just click the save button (don’t change anything, just re-save it). This resets the permalinks to your new URLs so the links to pages and posts will work throughout your site.

And that’s all folks!

Any questions, send me a comment below and I’ll see if I can help you.

76 thoughts on “13 Steps To Deploy WordPress From Your Localhost To A Live Web Server

    1. Good point! And yes, very doable that way. I might play that for my next website design project.

      I guess doing it my way avoids having to keep things in sync, especially if you don’t own the server on the other end. Also, the major reason for me is domain names can change partway through a project. I’ve had this happen a couple of times and it can be a pain in the neck.

      Whichever way you choose to do it, it’s good to document the workflow 🙂

  1. Here’s a related “gotcha.”

    If you use this (or similar) technique to move a site from one db to another db on the _same_ server, don’t forget to restart the server at some point.

    It really helps. Heh.

  2. Hello,

    I still have some trouble importing the .sql file to the web server. it always give error

    Error

    SQL query:


    — Database: `web1`

    — ——————————————————–

    — Table structure for table `wp_commentmeta`

    CREATE TABLE “wp_commentmeta”(
    “meta_id”bigint( 20 ) unsigned NOT NULL ,
    “comment_id”bigint( 20 ) unsigned NOT NULL default ‘0’,
    “meta_key”varchar( 255 ) default NULL ,
    “meta_value”longtext,
    PRIMARY KEY ( “meta_id” ) ,
    KEY “comment_id”( “comment_id” ) ,
    KEY “meta_key”( “meta_key” )
    ) AUTO_INCREMENT =1;

    MySQL said: Documentation
    #1064 – You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near ‘”wp_commentmeta” (
    “meta_id” bigint(20) unsigned NOT NULL,
    “comment_id” bi’ at line 11

    Please help

    1. Most common problem is that you forgot to use UTF8 character encoding.

      If you’re using jEdit check your buffer options under utilities menu and start again with the original file (always make a back up).

  3. Hi

    Good guide, but it should include that one may encounter an error such as:

    —————————-
    Error

    SQL query:


    — Database: `samfunnet`

    CREATE DATABASE `samfunnet` DEFAULT CHARACTER SET latin1 COLLATE latin1_swedish_ci;

    MySQL said: Documentation
    #1044 – Access denied for user ‘****’@’localhost’ to database ‘samfunnet’
    —————————-

    I found an answer somewhere (sorry, I closed the tab). Ach, but that did not fix it either.. all in all moving my WP site online is a great hassle for a newb like me ._.

    1. Hey Nicholas,

      Yeah it can be a pain in the ass the first time you do it. But it gets easier once you find a method that works.

      First up, check the character set that your database uses and make sure you are exporting under that character set and importing under the same set. You’re using latin1 and swedish for your database. That means step 6 will be save in whatever format you’re using.

      I just find UTF-8 is the most common storage character set on mysql databases and causes the least problems with character replacements. Some of the latin sets insert funky characters which will screw up all your posts.

      Second, when exporting, you usually don’t need to export the whole database, just the tables. So in phpMyAdmin make sure you’ve clicked on the database before pressing export and it will just export the tables.

      Most hosts will have a special tool for creating the database, so this is an important step as you won’t be able to create a new database in phpmyadmin with your user (which is the actual error you’ve received).

      All the best and feel free to comment again if you’re stuck.

    2. I know the question is old, but just to help others that might get here with the same problems.
      Delete line “CREATE DATABASE `samfunnet` DEFAULT CHARACTER SET latin1 COLLATE latin1_swedish_ci;” and add this right where it was:

      USE `samfunnet`;

      It should wokt now.

  4. Hi,

    This is a very useful post, just wanted some clarifications. I have a php mysql application package and I am trying to do web hosting for this application. I am told to do cPanel, Filezilla. Do I have to upload mysql separately and then the php part? or could I just upload the entire application zip through the filezilla?

    1. Hi Viji,

      Use filezilla to transfer the file to your server. Then you’ll need to setup the database via cPanel and then import it.

      Hope that helps!

  5. I have deployed wordpress from my local machine to server. I am getting the content but the images are not coming also the content is in the format,

    Please let me know what changes i have to do to get the blog in proper shape .

    you can visit the blog by clicking http://www.ileaf.in/blog

    Please help

    Thanks in advance

    1. Hey Mustafa,

      Looks like a lot of your files are still referencing localhost. If you look at the source for the page you’ll notice your stylesheet for example is pointing at localhost, you need to adjust all the addresses in any PHP files in your theme to point to your web server.

      Cheers,
      Josh

  6. Hi Josh,

    Thanks for your reply, I have done the necessary changes. My blog page is getting displayed . But after logging to the Admin Page (wp-login.php) while clicking on log in the next screen became white without any error message.

    Please let me know what the issue here.

    Thanks for your help

    Mustafa

    1. Hey Mustafa, did you replace the localhost entries in your SQL file before uploading to your server? Sounds like you might still have some entries as localhost rather than your url in your database.

  7. Hi

    I have created a website on my local PC under localhost/website. Now I wanted to upload this site to the actual URL which is under my college domain. The main website of the college is hosted from someplace else and I do not know the configuration of:

    1. PHP [mail function] for sending email to the registered users of my website to activate their account, which is currently not working.
    2. MySQL username, password, database name and hostname.
    3. I only have the username and password for FTP uploading for a website sub-domain.

    For uploading the website, I tried to:

    1. Export the current database to a .sql file using phpMyAdmin
    2. Create a new database
    3. Change the URL from http://localhost to http://mywebsite in the .sql file and wp_options table
    4. Import the .sql file to the new database
    5. Created a MySQL user and granted it all the rights for the new database with username and password
    6. Change the wp-config.php file with the name of new database, username, password and hostname as localhost
    7. Uploaded the contents of the website directory via FileZilla

    The problem is:
    The site is not accessible. It shows HTTP Error 500.

    My question is:

    1. What have I done wrong?
    2. Do I also need to upload the .sql file or should I ask the person who is hosting the main site to change the MySQL server settings (dbname, user, passwd, hostname) at his location?
    3. What can I do enable sending of emails from the site: Ask the hosting person to give the addr and port of smtp server and change it at my location or ask him to change it at his location?
    I have started using WP 2 days back and I would be thankful if someone answers my questions about MySQL and PHP [mail function].

    Thanks

    1. Hey Raj,

      That’s one big comment 😀 I’ll do my best to help…

      My question to you: If you don’t know the MySQL details of your host then where did you upload your .sql file after changing the URL? Do you have access to the remote server’s phpMyAdmin console?

      If you’re receiving a HTTP Error 500, my first step is usually to goto the wp-config.php and turn on debug mode which will give you the PHP error output.

      Look for the line:

      define('WP_DEBUG', false);

      And replace it with:

      define('WP_DEBUG', true);

      As for the mailing issue.. that’s usually PHP mail isn’t setup on the host. It could be that your local machine doesn’t have it setup (some copies of XAMPP don’t have it on by default for example). I’d wait until you sort out the other issues before troubleshooting this, but it’s likely something your host will need to change.

      Cheers,
      Josh

  8. Thanks for replying Josh… nobody was replying on other sites

    I do not have access to the remote server’s phpMyAdmin or MySQL… now that you asked I think I have been doing it locally and this seems to be the fault.

    I think I will ask my employer to give me a MySQL and phpMyAdmin username so that I can access server control panel remotely. Is this right?

    Thanks Again

    1. No worries mate.

      Yep you’re exactly right, the SQL needs to be uploaded to the remote host’s MySQL which would be why your site can’t find what it needs.

      Come back if you have more problems, sounds like you’re a cluey guy though so I’m sure you’ll figure it out if you’ve managed to work out WordPress in 2 days!

  9. Hi…

    We are creating one site in wordpress at localhost using xamplite. But when we deploy it on server its shows some database error, we solve it by using phpmyadmin import and export function. And also change the name in localhost to our current domain name in .SQL file.

    But still its shows the category page as http://localhost/demo/ or http://localhost/demo/?page_id=2

    so please help us. Where we want to change.

    Thanks,
    Sudhakar & Team

    1. Hey Sudhakar, if it’s still showing localhost then there must still be some entries in the SQL as localhost. Make sure you do a string replace using a tool like jEdit otherwise you’re likely to miss some if you’re just going over the file by hand.

  10. hi, i have prob i make wordpress website in my own folder. when i transfer site all time wp-admin page not open original site but open old site please help me.

    1. Hey Rajan,

      So you put WordPress in a subdirectory? Well you need to add that directory to your URL before the wp-admin bit to login. You’ll also need to make sure that you change your links in your database. It’ll be a real mess if you didn’t have it in it’s own subdirectory when you were developing it in your localhost though… best of luck!

  11. Hi Josh Kohlbach,
    Please I really need your help in details. I have follow the 13 steps to upload my local site to live website but here is the message received whenever I visit the site:

    401 – Unauthorized: Access is denied due to invalid credentials.
    You do not have permission to view this directory or page using the credentials that you supplied.

    I set up the database but i don’t know how to allot “full user permissions” to the user.

    elp please.

    1. Hey William,

      401 unauthorized access sounds like it could be a htaccess problem. Delete the .htaccess file from your root directory and see if that helps.

      Cheers,
      Josh

    2. Thanks. It really helped. immediately you mentioned .htaccess, i used google to search for all .htaccess related problems and i found out that there is a need to request for .htaccess setup by my host. They did and call it web.config. Thereafter, i am able to visit and login-in to admin panel.

      But, I discovered that all the products pictures are not showing unless you select and zoom. I used eshop template. Please, visit nbcpublications.com and help me out.

      Thanks for the great job you’re doing. More grease to your elbow.

      Cheers.

  12. This worded perfectly. The only other thing I needed to do was use WP Migrate DB to move MYSQL Database over. Check it out, what do you think?

    Thanks by the way for posting this. I learned a lot from this. Noob here.

  13. Thanks for sharing 🙂
    Probably, the most important point is 10, it’s fundamental to change every local path to new one.

    This is the main problem people found when they trasfer WordPress from local installation.

  14. I am trying to transfer my wordpress site from one computer to another.In both Wampp and Xampp servers..It can only run with the theme without the content.What might be the problem….

    1. Hi Peter, check that you don’t have any hard coded links in your theme files. Also check that your followed the steps properly when you transferred the database, it’s important that you do the string replace on the URLs in your .sql file before importing into your new DB.

      Finally, double check you have the right DB credentials in your new site and it’s not referring to the old database.

      Other than these things you’d need to provide more information so I can get a better idea of what the problem might be.

  15. Hey Josh, I followed this and it seems that my site is still linking to the local server even though I’ve done found and replace and changed everything in the SQL file. Any ideas why that would occur?

    Thank you for the tutorial!

    1. Hey Lindsey,

      This probably means there’s some URLs in the database that weren’t changed or some of these links are hard coded in your theme. Are you 100% sure that string replacement worked, and you imported the altered SQL file not the original? Easiest way to check is if the URL in Settings->General is still localhost or not.

  16. hi josh! great tutorial! but i have a really big problem of visualization of the content in my site…

    If i write it’s because i really spent lot of times for the solution, but i didn’t find anything useful. Your guide is great and i felt both happy (cause i done all that you said and the migration was successful) both sad because i can’t understand what’s happening…

    I succesfully migrate the website. But the are really a lot of elements who doesn’t work at all. My homepage is different from what i did in localhost, there is no header image, no sidebar either with all her widgets! no loop of posts! the pages are really messed up, layout too..i don’t know what i m doing wrong. You can see the site here : http://www.lidia.me

    What i did:
    0) I went to localhost folder wamp/www/joedoeblog/blog/
    1) (Localhost) open PhpmyAdmin and exported the same database of the localhost in a .sql format
    2) edited with notepad+++ this file and change every reference to the localhost with the website url http://www.lidia.me (so for example if i had localhost/joedoeblog/blog/wpcontent…now i have http://www.lidia.me/wpcontent….)
    3)loaded the edited database to the phpmyadmin of my hosting service.
    4) loaded the wordpress folder of the localhost in the /public_html folder of my hosting web server (as it mentioned to do that), thanks to Filezilla.
    5) changed wp_config with the exact name of database.
    6) saved permalink

    don’t know why i have a bad visualization of the content; the content exists, but it seems like the order of the page is messed up..the only page which seems (at least a little) to work is the ABOUT page..everything is in the exact same directory as always.

    thanks for your patience!

    1. Hey Marco, firstly good work on making it that far.

      It seems you have a call to an undefined function in one of your files, here’s the error:

      Fatal error: Call to undefined function sharing_display() in wp-content/themes/twentytwelvechild/content.php on line 103

      So I’d start by looking into that. Is that plugin not enabled properly perhaps?

      Regarding the widgets, sometimes this happens with the text widgets if they have the URL in them as they store it as a serialised string. Just copy over the widgets from your localhost version and change the urls by hand.

      If you have some money to spend you could look at using something like BackupBuddy, I’ve been using it a lot lately to transfer sites as it’s a big timesaver.

      Best of luck!

  17. thanks josh…i can’t believe my eyes…for a simple string that i modified to get a plugin works, all was messed up. Incredible. Now it works! there are still problems with the YARPP plugin and some URL of text widget, but it works lot better….

    i think i don’t like web-developping because really, the mistake can be very small and apparently without any rilevance.

    thanks josh!

  18. Josh! Thank you so much for this great tutorial.
    I tried all 13 steps but i keep having problems with css and javascript.. the website seems like it has no css file. I tried linking all the theme css files by hand through header.php and it worked but all the jquery scripts kept on not working. The site works perfectly on my localhost but everytime I upload.. there are problems.
    Do you know why this could be?
    Thank you so much!

    1. No worries David.

      Try searching your theme’s files for any localhost URLs, sounds like either there might be some urls pointing to localhost for your CSS. You can confirm this by Inspecting using Chrome or Safari (or with Firebug addon for Firefox) and searching for localhost.

      Best of luck!

  19. Hi there! I get this error from phpMyAdmin when I try to import my sql file into the new database on the live server:

    #1103 – Incorrect table name

    Any ideas on what I might be doing wrong?

    1. Hi Gwen, make sure you are importing into a new, completely empty database. Otherwise, double check your options when you export the local copy.

    2. Thanks Josh. I ended up changing the database name in the sql file to include the prefix it was showing up with at the top of the phpMyAdmin screen (not the only WordPress site being hosted on the server), then it imported without a problem.

      Sharing this here just in case it helps someone else experiencing the same problem!

  20. just found there is a plugin called duplicator that can move wordpress from site to site….and there is video which shows the site being cloned, downloaded, and then installed on i think personal system…what is your view on that… would that do what you are explaining without any hassle of messing up…????

    1. BackupBuddy would be another one to use. The above process is if you want to do it all manually and really understand how it all works. It was also written quite a while back when these types of tools didn’t really exist!

  21. pls when I try to edit and view my index.php file on filezilla,it brings an error message but it open on the desktop.

  22. So, as a complete noob. I bought a WordPress domain and name, and the 2nd package. Then bought a theme on another site. The site requires me to use local host. How do I sync the local host wp with the site I have on wp? Or is this the same?

Leave a Reply

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