After you uploaded your wordpress site on the internet, you would still want to have a copy on your local machine for easy development process.
This section will guide you how transfer your files from internet to your local machine. In this case, let’s use XAMPP as our local server. Check the items below.
Important: It is highly recommended to back up your files before making changes.
- Transfer your files from your web server into your localhost
a. Connect to your FTP and,
b. Copy files into your local PC where your local server is located.
On my computer, I have installed a XAMPP server, therefore I have saved the files inside the htdocs folder.Note that, you must have installed a local server in your computer, if not, you could not be able to proceed below.
- Database Setup.
a. Export your database:
Go to your web server and access your phpmyadmin. If you are already in phpmyadmin of web server, select your database and export it.
b. Import into your local phpmyadmin:
Once you have successfully exported your database, import your database into your localhost/phpmyadmin. In this case, you might be experiencing difficulty in uploading of big database file. If this will happen, I suggest you to create .htaccess to change the PHP setting.
php_value upload_max_filesize 100M //file size
php_value post_max_size 100M
php_value max_execution_time 200
php_value max_input_time 200
- Update your database sql
After importing your database into your localhost»phpmyadmin , you need to update the URL of your website by executing the sql query below:
UPDATE wp_options SET option_value = replace(option_value, 'http://www.your_site.com', 'http://localhost/your-site-name') WHERE option_name = 'home' OR option_name = 'siteurl';
UPDATE wp_posts SET post_content = replace(post_content, 'http://www.your_site.com', 'http://localhost/your-site-name');
UPDATE wp_postmeta SET meta_value = replace(meta_value,'http://www.your_site.com','http://localhost/your-site-name');
- Configure your localhost site in order to connect to your database
Go to the folder where you saved your wordpress site in your localPC (inside the htdocs) and open the wp-config.php file using a text-editor. After opening the file, change the database name based on the new name you created on localhost/phpmyadmin, and also for the username and password. Commonly, username is ‘root’ and password is ” (empty).
/** The name of the database for WordPress */
/** MySQL database username */
/** MySQL database password */
- Recheck the URL
And now, open a browser and visit your site (http://localhost/your-site-name). If the url is not redirecting properly (because you might have saved it inside the sub folders), then go to wp-config.php and paste the code below:
define( 'WP_SITEURL', 'http://localhost/your-site-name' );
define( 'WP_HOME', 'http://localhost/your-site-name' );
Then, you are done!
Just in case your-site looks messy, login to your
http://localhost/your-site-name/wp-admin, and enable the plugins. I hope this simple tutorial which I’ve also learned during development will help you.