How to transfer your website from live server to localhost without using a plugin

by Sam  

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.

  1. 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.

    example. C:\xampp\htdocs\your-site-name\

    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.

  2. 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
  3. 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://localhost/your-site-name') WHERE option_name = 'home' OR option_name = 'siteurl';
    UPDATE wp_posts SET post_content = replace(post_content, '', 'http://localhost/your-site-name');
    UPDATE wp_postmeta SET meta_value = replace(meta_value,'','http://localhost/your-site-name');
  4. 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 */
    define('DB_NAME', 'database_name_here');

    /** MySQL database username */
    define('DB_USER', 'username_here');

    /** MySQL database password */
    define('DB_PASSWORD', 'password_here');

  5. 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.

Leave a Reply

Your email address will not be published. Required fields are marked *

Need of a Website?

Maybe you're planning to build a landing page for your website. You might also have a plan to create a web application. I can offer you with an affordable but with good quality services. Don't hesitate to submit your specifications by clicking the button below.

Get Quote