How I duplicated my live site on wampserver localhost for testing

I had difficulty duplicating my live site on my wampserver. I spent nearly two days and ran into a variety of problems from errors in database, to site appearing offline, 404 errors, images not showing etc. My online searches for solutions to problems that arose led me to changes in htaccess, index.php, site html, apache, sql and more to no avail. I am a beginner and not a programmer of any sort. So once I did figure it out, I thought I share how I managed to duplicate my live site on localhost and hopefully help other adventurerous souls coming to the land of drupal.

  1. I created a new database using phpmyadmin and assigned it a user with all the privaleges - administrator.
  2. Prepared my installation by extracting standard drupal core into a folder (I called it testsite)and then placing the same modules as my live site into sites/all/modules folder. I further placed my theme in the sites/all/themes folder. All this is before installation.
  3. Then, I copied the prepared drupal core folder into wampserver "www" folder
  4. Performed the standard drupal installation by opening the web browser and typing localhost/testsite and following the prompts.
  5. I enabled all the same modules as my live site on the local installation.
  6. Then I copied the files folder (sites/default/files) from my live site and placed it at the same location within my "testsite" installation on localhost (www folder)
  7. Flushed all caches on the live site, and then used backup and migrate module to backup and download the default database
  8. On local testsite, opened backup and migrate module and restored database using the downloaded mysql file.
  9. Clicked on wampserver icon -> apache->and checked rewrite module is on


  10. Went to test site and saw everything was working except for images. They only showed if the clean urls were turned off.
  11. ** Note: I later saw that this created some extra folders on my hard-drive. Maybe just leaving clean urls off is a better solution.Opened up an article and inserted an image. My images were located in sites/default/files but now this path no longer worked. I tried changing the path in configuration->file system but this didn't work. I noticed that the path of an inserted image was testsite/sites/default/files on localhost. I noted the image url and then ran a sql query to change paths.
  12. UPDATE `field_data_body` SET `body_value` = replace(`body_value`,'sites/default/files','testsite/sites/default/files')



    I turned clean urls on and everything worked.