How to put a new version of a WP site live

If you already have a wordpress site live on a server, it can be a scary thought putting a new one live. Replacing the databases? Replacing the uploads and wp-content, the plugins. Argh!!

Step 1

  • Locally, duplicate the database and run a replace tool to swap your local url to the live url
  • Make a second database on the server
  • Upload the correct file

You now have 2 databases on the server, the old one, still running the site, and the new one sitting idly by.

Step 2

  • Create a new subdirectory and upload the whole Wordpress install into it
  • For the purposes of this I will assume that the subdirectory is called SUBDIRECTORY
  • Now, in the SUBDIRECTORY folder, open the wp-config.php file and update all the database details to be the same as the new database.

You now have all the files you need, ready to go, on the live server in a folder called SUBDIRECTORY, and you also have the database setup, however at present you aren’t using any of these things, the live site is still there.

Step 3 Connect the subdirectory to MySQL

  • Open PHPmyadmin and go to the new database
  • Open the wp_options table
  • Update JUST the siteurl to the correct directory of your files, for instance
  • Now edit the index.php file in the ROOT directory of the site
  • Replace the line similar to this to say:
    require( dirname( __FILE__ ) . '/SUBDIRECTORY/wp-blog-header.php' );

Did you mess it up?

Just put that last line in the index.php back to as it was (so remove SUBDIRECTORY/)

Regex find a whole plugin

Just put a comment before the beginning and end of the plugin, for instance: /* FITVIDSFITVIDSFITVIDSFITVIDS */

Then in Sublime text, find, switch on Regex and copy the following, replacing the two FITVIDSFITVIDSFITVIDSFITVIDS bits.


Laravel notes

I recently started using the fantastic Laravel for a number of PHP web projects.

Being from a Wordpress background the learning curve has been pretty steep – but I started writing down every problem I had and how I fixed it. You can find my 'research' here:

Laravel Notes