There are steps which we need to transferring the site from local machine to online computer or one ip to another ip should be the same. Here are the steps to copy a wordpress site to your local installation.
Before we start lets define a few things for this example:
- The hosted version address we will refer to as: http://www.pkbhandari.com or http://oldurl.com (This is the web address of the hosted wordpress site)
- The local version address we will refer to as: http://localhost/testsite or http://192.168.1.2/testsite (This is the web address of the local host folder you want to transfer your site to)
Copy your files from your localhost to your online server site available folder to server folder or online to localhost vice versa.
Export your database from the source site. save the file to zip.
(By Selecting your database and selecting the export tab and downloading to your computer)
Log into your [destination] local phpmyadmin, create a new database and import the sql database into it by selecting the import tab and uploading your file.
you need to create any database for you destination database name. It also might be same as online database name. as your choice.
Once Uploaded we want to modify the database to reflect the new blog location being on the localhost.
So we run the following SQL (Select the SQL tab and paste the following code):UPDATE wp_options SET option_value = replace(option_value, ‘http://oldurl.com’, ‘http://localhost/newsite’) WHERE option_name = ‘home’ OR option_name = ‘siteurl’;
This query can update your site url and home page link of the site.
Wp Admin => Setting => General
WordPress Address (URL) and Site Address (URL)
We now want to fix the urls of posts and pages. So we run the following SQL:
UPDATE wp_posts SET guid = replace(guid, ‘http://oldurl.com’,’http://localhost/newsite’);
It should change the all (guid) guide path of post and page content of WP_POSTS table.
If you have linked internally within blog posts or pages with absolute URLs, these links will point to wrong locations after you move the blog location. So we run the following SQL to fix this issue:UPDATE wp_posts SET post_content = replace(post_content, ‘http://oldurl.com’, ‘http://localhost/newsite’);
All the media files images,video,audio internal links will be changed to new site path url.
We want to now modify our wp-config.php file in our local server.All the database configuration need to be changed with our local database name, database user and password.
// ** MySQL settings – You can get this info from your web host ** //
/** The name of the database for WordPress */
/** MySQL database username */
/** MySQL database password */
Fill in all of the fields:
Database Name: This is the name of the database in your local phpmyadmin
Username: This is your phpmyadmin username (usually root)
Password: This is your phpmyadmin username’s password (usually null)
Database Host: This is usually localhost
Database Prefix: normally is wp_ unless someone has changed it manually.
I hope this helps for all.