Publishing WordPress site from development to production server – or moving your WordPress installation from one host to another

WordPressYou have finished that WordPress site, and want to deploy it – move it from your test server to the production server where it goes live. But how? WordPress have a famous 5-minute-install, but there is no 5-minute-go-live-script*. I’ll show you how in these 5 easy-to-follow steps.

Going live really isn’t that difficult, as long as you have terminal/SSH access to both your development server and your live server. If you develop locally on your Mac, Terminal will work just fine. If you don’t have SSH access to your servers, ask your provider and they should give it to you (and if not, switch provider!).

Step 1: Wrapping together your files and dumping your database

First step is to package all your files into an archive for easy and fast upload, and creating a database dump – a copy of your database stored in a file.

Open up your terminal (ssh to your dev server if necessary) and go to the directory where you have your WordPress files (change Documents/webroot/wordpress with the path to where you have stored your files, of course):

$ cd Documents/webroot/wordpress

Create a gzip’ed tar archive of your files:

$ tar zcvf wordpress.tar.gz *

If you have forgotten your MySQL credentials, run the following command to show them:

$ grep 'DB_' wp-config.php

Create the gzip’ed database dump:

$ mysqldump -u mysql_username -p mysql_database | gzip > wordpress.sql.gz

You should now have the files wordpress.tar.gz and wordpress.sql.gz ready to be transferred to your production server.

Step 2: Transferring your files

If your files are on your local computer, you can use an SFTP client like Transmit (Commercial, Mac), CyberDuck (Open Source, Mac) or FileZilla (Open Source, Mac/Windows), but it’s just as easy using scp – which you should use if you’re transferring server-to-server:

$ scp wordpress.{tar,sql}.gz [email protected]:/path/to/your/webroot

Step 3: Extract your files and import your database

SSH into your production server and go to your webroot:

$ cd /path/to/your/webroot

Extract your files:

$ tar zxvf wordpress.tar.gz

Import your database. If you don’t remember your MySQL credentials, ask your hosting provider:

$ gunzip -c wordpress.sql.gz | mysql -u mysql_username -p mysql_database

Now edit wp-config.php and update the database config with the MySQL credentials for your production server.

$ nano wp-config.php

Cleanup by removing the uploaded archives. There’s a HUGE security risk by leaving them in place:

$ rm wordpress.*.gz

Make sure your files and directories have the correct permissions (if these settings are wrong, you should really change provider):

$ find . -type f -exec chmod 0644 {} \;
$ find . -type d -exec chmod 0755 {} \;
$ chmod 0600 wp-config.php

Step 4: Update the database with new hostname

If you are simply switching hosting and are keeping the same hostname, you can skip this step.

Log in to your database:

$ mysql -u mysql_username -p mysql_database

Update your config:

mysql> UPDATE `wp_options` SET `option_value` = REPLACE( `option_value`, "", "" ) WHERE `option_name` IN ("siteurl", "home");

Update all internal links you may have in your content:

mysql> UPDATE `wp_posts` SET `post_content` = REPLACE( `post_content`, "", "" );

Step 5: Generate your .htaccess file

If you’re running WordPress on Apache, you might want to log into the dashboard and visit the Settings > Permalinks page to generate your .htaccess file so everything runs smoothly.

* Actually, with the commercial plugin BackupBuddy, there is a migration script that works in the same manner as the 5-minute install script.


  1. What about moving content ( posts ) from Dev to production. My prod server was recently hacked and they ruined the server and the backups that were on the ISP’s host.

    my plan is to edit and review posts on my development instance, and promote / publish them to production. This gives me a safe place play with ideas, and also provides a server that is a backup of the production server that is protected by my private network’s firewall.

  2. same here, i have a dev wp site on local, with new pages creates and change in the homepage with new images , i want to deploy all these changes from dev site to production which is already live running .

    Do i have to dump the dev database and export into the live running production env ? sounds crazy

Comments are closed.