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
- phpMyAdmin
- jEdit (or other editor able to do global string replacements and save in UTF-8 format)
- FileZilla
Steps to Deploy WordPress From Localhost To Your Web Server
- Export your DB from the localhost using phpMyAdmin as a .zip
- Extract the zip locally somewhere for editing
- Open the .sql file in jEdit (or equivalent UTF-8 capable editor) and do a string search for localhost
- Find the string you need to replace, usually http://localhost/your-site depending on how you’ve setup your local server.
- Do a global string replace using the replacement string you found and replace it with your new domain, something like http://your-domain.com
- Save in UTF-8 format. You might want to save as a new file just in case you need to revert.
- 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.
- Using FileZilla (or equivalent FTP program) upload your website’s files to the web server.
- 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.
- 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.
- Save this as wp-config.production.php and upload to your web server.
- 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.
- 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.
Did you like this article?
If you liked this article click one of the buttons below:
Claim your FREE report
"3 quick ways you can start making money as a programmer today"
15 Comments
Scroll down or click here to leave your comment!
Leave a Reply
Pingbacks/Trackbacks
-
Pingback: JKWEBCO | Web Design Co. » Dude, PHP and the knot Website, Design, Site, Customized, Stuart FL
-
Pingback: 13 Steps To Deploy WordPress From Your Localhost To A Live Web Server | Design Newz
-
Pingback: 13 Steps To Deploy WordPress From Your Localhost To A Live Web Server | The best Tutorials
-
Pingback: 13 Steps To Deploy WordPress From Your Localhost To A Live Web Server | WebDevKungfu
-
Pingback: Speed Up Your Wordpress Development Cycle With Git « Clint Berry



Why not set up /etc/hosts and your httpd.conf to point the domain at 127.0.0.1 instead? That’s a bit of pain, but not as much as doing this. I know this from experience!
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
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.
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
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).
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 ._.
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.
thank you this really helped
Glad you found it helpful Blruk