Part of my workflow when developing Wordpress based websites is to import a brand new Wordpress install into Subversion, then check it out and develop on my local machine using an all in one LAMP stack such as XAMPP. Once I’m happy with the results I then copy it across to a staging production server, again using a SVN checkout. I’ve been using a great tutorial at http://mark-kirby.co.uk/2008/how-to-create-a-local-copy-of-a-wordpress-site/ to copy Wordpress installs and it deals well with the issues concerning moving Wordpress installs between local and remote servers, essentially boiling down to the following procedure:
- back up the existing Wordpress database: Using phpmyadmin, select the original WP database in the left menu and click the ‘Export’ tab, then tick ‘Save as file’, choose either ‘zipped’ or ‘gzipped’ and click ‘Go’.
- create a new database on your staging site: Using phpmyadmin, select the ‘Privaliges’ tab, select ‘Create a new user’, fill in and take note of the fields as appropriate, select the option to ‘Create a database of the same name and grant all privaliges’, and click ‘Go’. Then modify two fields within the
siteurlshould point to your new URL.
- Import the backup of the existing Wordpress database into the new database you just created, by selecting the newly created database on the left menu in phpmyadmin and clicking the ‘Import’ tab.
- copy the existing Wordpress file structure as is into your staging area and update the database connection fields in
DB_HOSTshould be altered to reflect the new user/table structure.
If you now navigate to your new Wordpress URL, you should see your blog homepage and I usually go straight into
/wp-admin, regenerate permalinks (which regenerates
.htaccess for the new URL) and reinstall any plugins that have cached the old URL (not many do this fortunately enough).
Now I’ve done this many a time with great success, but recently I’d followed this procedure exactly (or thought I had) but this time got a 500 Server Error when trying to navigate to home page of the staging server WP install.
After spending a little time searching for ‘Wordpress 500 Server errors’ and checking through numerous log files I thought lets check
/wp-admin, and got a helpful message:
This highlighted the fact I’d correctly copied over the database but that there was something wrong with the Wordpress database user permissions. So my lesson of the day: If you do get a 500 Server Error, first check
/wp-admin, you may get a more useful error message!