Issue:  We wanted to test run a Wordpress plugin without risking the live site.  In the past we have had plugins bring the site to it's knees, lost data, etc.  This was a site that someone else had set up in the beginning, and we had inheirited it for updates and maintenance.  It is a Wordpress 3.5 site with a YooTheme that is no longer supported - so we are reluctant to just upgrade the site to the latest version of Wordpress.

I had a choice of copying the site to a subdirectory on the host server and copying the database over, etc. or copy a backup of the database and the site to my local WAMP setup.  The hosting company support and their client interface is a bit iffy - so I chose the latter.

Of course I went through the steps of creating a new database in phpmyadmin and importing the database copy from the live site and editing the wp-config.php file to find that database.  No problem there.  The local site found the database with no issues.

I have tried doing this before - move and existing Wordpress site - to my local machine with the WAMP setup.  The problem I had was if it was installed in a sub-directory in my www folder on my WAMP install, the site won't see all of the files - especially the css.  I thought maybe if I temporarily move all my other folders on the WAMP -> www folder to a sub-folder and installed the Wordpress site on the root, it would work.  

I found out that it was not a fix to go this route.  What happens is your database still has the live site's url in it and when you launch your local wordpress site - it defaults to the live site.  If you go into the back end - you are in the backend of the LIVE site.  

So I researched a bit more and found a very nice article (older article - 2008 - but the info still applied to my situation) from a web developer named Mike Kirby "How to create a local copy of a wordpress site".

You don't have to install Wordpress on the root of your WAMP site - you can install it in a sub-directory. You just need to edit the database so it know where to look for the local site. Essentially, what you need to do is open up phpMyAdmin and change a couple of things in the local database.  

  1. Launch phpMyAdmin from your WAMP icon
  2. Open up the approprate database.
  3. Select the table wp_options
  4. Select browse
  5. Locate the option 'siteurl' and edit is so the option_value becomes http://localhost/localfoldername
  6. Locate the option 'home' and edit it so that the option_value becomeshttp://localhost/localfoldername

If all is well, when you launch your Wordpress site, you should see that there is localhost in the address bar. You can then go about testing new plugins without risking harm to the live site. There is a caveat here - your local php build and setting may be different that that of your hosting company - so you are not really dealling with the same environment.

There is another step that you need to take to view the interior pages of your Wordpress site.  You need to edit the .htaccess file.  You need to path to the subfolder (chances are if you have a WAMP environment, you have multiple sites in the in subfolders of the www directory).

# BEGIN WordPress
<IfModule mod_rewrite.c>
RewriteEngine On
RewriteBase /myfolder/
RewriteRule ^index\.php$ - [L]
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule . /myfolder/index.php [L]
</IfModule>
# END WordPress

 

Also, if you plan to move this database back to the host server - you need to go back into the phpMyAdmin there and change these settings to see your site's live url and edit the .htaccess.