4

I'm trying to move a big site that's currently live onto my local machine so I can edit locally. I'm using Wamp Server. I've tried using the Duplicator plugin but I'm getting several warnings and errors when I try to unpackage it locally. Is there a more foolproof way to do this?

Otherwise, would it be easier to move the live site onto a sub-domain on my personal site? Something like 'site.com/clients/test-site'? I just need an environment where I can make changes without affecting the live site.

1 Answer 1

7

Why didn't you try to copy your live website manually. It's not as easy as using a plugin but much more error proof. You will need to follow these steps.

  1. Make a dump of MYSQL database on server.

    mysqldump -u username -p -h localhost dbname > domain.sql
    
  2. Create a archive of your WordPress website on server.

    tar -czf domain.tar.gz domain.com
    
  3. Download both on local machine. And extract the archive.

    tar -xzf domain.tar.gz
    
  4. Import database at local machine.

    mysql -u username -p -h localhost dbname < domain.sql
    
  5. Now change wp-config.php values for local server.

  6. Change domain name in MySQL. You can run these mysql queries to replace it with local domain setup.

    UPDATE wp_options SET option_value = replace(option_value, 'http://www.oldurl.com', 'http://www.newurl.com') WHERE option_name = 'home' OR option_name = 'siteurl';
    UPDATE wp_posts SET guid = replace(guid, 'http://www.oldurl.com','http://www.newurl.com');
    UPDATE wp_posts SET post_content = replace(post_content, 'http://www.oldurl.com', 'http://www.newurl.com');
    UPDATE wp_postmeta SET meta_value = replace(meta_value,'http://www.oldurl.com','http://www.newurl.com');
    

Or simply define these in wp-config.php, these will overwrite domain URLs in database. I think this will be better for local development.

define( 'WP_HOME', 'http://example.com/blog' );
define( 'WP_SITEURL', 'http://example.com/blog' );
  1. Done.

I develop and move nearly 7-10 WordPress websites each month and this is what I do. I can't say it's better than using a plugin or any other migration tool but it's more controlled. And once you get familiar with the process, there are very less chances of error.

7
  • 1
    After a couple years of working with Wordpress, this became basically my default process as well, good stuff @Roberthue. I still used interconnectit's search and replace script for the db but that was only because it's so reliable and handled length for serialized entries too. OP, this might all sound a bit complicated, but learning the process inside and out will make you a much better developer for your clients that need WordPress work. Commented Oct 30, 2014 at 4:16
  • @AndrewBartel thank you for mentioning. I also use interconnectit's search and replace script but I didn't mention it here because I did not want to scare him with another 3rd party script. And also I think nterconnectit's script has much better use for websites that you want to move. For local development purpose, defining WP_HOME and WP_SITEURL in wp-config.php will work fine.
    – Robert hue
    Commented Oct 30, 2014 at 4:55
  • This guy has it. If you're not into SSH it's doable using PHPMyAdmin to export your database.
    – Joshua
    Commented Oct 30, 2014 at 5:26
  • 1
    @Joshua yes, this whole process require SSH access. And I assumed he has it because almost all hosts offer SSH access these days. :)
    – Robert hue
    Commented Oct 30, 2014 at 5:34
  • It's too much command line for me :P
    – Joshua
    Commented Oct 30, 2014 at 5:38

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.