Step-By-Step Guide to Putting a WordPress Site Live

July 25th, 2011 - Posted by Steve Marks to MySQL, PHP, Web Development.

Putting a website live normally involves transferring files from a development area into a live webspace and, depending on the site, moving a database too. The process is essentially the same when putting a WordPress site live but there are a few additional steps required to get fully up and running.

Below I’ll walk through each of the steps required to get your WordPress site live and fully functional:

1. Move the database

WordPress has a MySQL database that consists of around 11 tables (this may differ based on any additional plugins installed). The first step in the process is to transfer this database to the live environment ensuring that a sufficient MySQL user has been setup and the details are reflected in the wp-config.php file.

wp-config.php is located in the root of the WordPress installation and contains various settings for your installation including database connection information, security keys and more. In this instance we are interested in the database information around line 19 onwards so ensure the DB_NAME, DB_USER, DB_PASSWORD and DB_HOST options here are correct and valid:

// ** MySQL settings - You can get this info from your web host ** //
/** The name of the database for WordPress */
define('DB_NAME', '');

/** MySQL database username */
define('DB_USER', '');

/** MySQL database password */
define('DB_PASSWORD', '');

/** MySQL hostname */
define('DB_HOST', '');

2. Update the sites URL

Now that the database is copied over there are two options in the wp_options table that are hardcoded and that we need to update to reflect the URL of the new site. These options are called ‘siteurl’ and ‘home’. Simply change these using a database admin tool, or alternatively run the two MySQL queries below:

UPDATE `wp_options` SET `siteurl`='';

UPDATE `wp_options` SET `home`='';

Excellent. We’re halfway there. Next another database change…

3. Replace any hardcoded links

UPDATE 24th May 2014 – Rather than manually executing the below SQL queries I’ve since found a much better, more reliable way to replace any hardcoded URL’s that exist in the database. This can be achieved using the script from website below:

The old, development URL was hardcoded in the wp_options table in the last step. If you’ve added an image or uploaded a document via the TineMCE WYSIWG within WordPress the link to this media file will also be hardcoded in the posts body. To go through each post manually to update these fixed URLs’ would be quite painful so instead I give you another MySQL query to run that will update these links across all posts:

UPDATE `wp_posts` SET `post_content`=REPLACE(`post_content`, '', '');

UPDATE `wp_posts` SET `guid`=REPLACE(`guid`, '', '');

Note: Depending on the plugins you have installed there may be other references to the URL’s in other locations such as the wp_options table, or any tables that the plugins may have added upon activation. I recommend you do NOT run the REPLACE command on these. Why? Because sometimes, especially in wp_options, the URL will be part of a serialized array. Changing the URL will make these serialized arrays invalid and could cause the plugin to stop working. Sometimes deactivating the plugin and re-activating it will sort these out, otherwise best to do it manually.

4. Transfer the files

OK, that’s the database side of things done. Now all that’s left to do is move the WordPress files over to the live environment via FTP. Remember to take a backup if an existing site is being replaced. This can take a couple of minutes but once done you should be able to visit the URL and admire all your hard work.

Note: Permissions

It is recommended that you double check the permissions on folders once the files have been transferred. If you’re planning on uploading files through WordPress, enabling caching or using plugins it’s worth checking that all these features have the right access. Click here for more information on setting WordPress permissions.

This entry was posted on Monday, July 25th, 2011 at 10:04 pm by +Steve Marks and is filed under MySQL, PHP, Web Development. You can follow any responses to this entry through the RSS 2.0 feed.

Fear not, we won't publish this

Comments (0)

No comments have been left yet. Be the first