Setup a local copy of a WordPress site

How to create a local copy of your live wordpress site in 6 easy steps.

Prerequisites:

  •  Linux operating system with the LAMP software bundle already installed, configured and secured.
  • The Apache mod_rewrite module must be enabled.

 

Steps to setup a local copy of your WordPress site

 

√ Step 1.
Export the live database contents.

 

√ Step 2.

Export the live wordpress install.

… your hosting provider will usually assists with above steps.

√ Step 3.

Update the database dump  obtained in step 1) above to replace all references to the <live host> with locahost

sed -i ‘s/livehost.com/localhost/g‘ live_database_dump.sql

√ Step 4.

Import the modified sql file into a mysql database
mysql -u <username> -p <pwd> <database> < live_database_dump.sql

√ Step 5.

Extract the live WordPress files obtained in step 2) under /var/www/html

√ Step 6.

Modify wp-config.php to point to the local database and the local host.

define( ‘DB_NAME’, <local database> );
define( ‘DB_USER’, <db user> );
define( ‘DB_PASSWORD’, <db pwd>);
define( ‘WP_SITEURL’, ‘http://localhost‘ );
define( ‘WP_HOME’, ‘http://localhost‘ );

 

Advertisements

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s