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
- jEdit (or other editor able to do global string replacements and save in UTF-8 format)
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.