How to Migrate a Website Built In WordPress to the Localhost

by | Apr 2, 2020 | Web Development Tutorials | 0 comments

This article is aimed for those people who, regardless of the reason, attempt to change their website or their blog developed in WordPress from an external hosting to a local one, localhost, but retaining the content and functionalities of their websites intact. 
This procedure is quite interesting because, with an exact and functional local copy of your website (it only works on your computer), you have the possibility to do all the tests, updates or changes you want, in a controlled and even friendlier environment. If something fails or breaks,

or a “mission: impossible” self-destruct message appears, it’s ok; nothing happens, it is just a copy of your website.

Let’s begin, it is just four simple steps:

1. Start by creating a copy or backup of all of the content of the website.

If your website is hosted on an external server, which is the common scenario, you can obtain this backup either through a specialized plugin such as Duplicator or through the “backup” option that is included in the interface of any Cpanel.

If for some reason the database file was not included in this backup (it is a file in .sql format), you must make that copy manually by going to phpMyAdmin, selecting the database in the correct SQL format, then selecting the “export” button.  

If your website is in a Github repository in its full version, it’s even easier. (Remember that we are talking about pages that are built with WordPress). You just need to make the clone or fork of that repository, a direct download, or a copy-paste to have the complete folders on your computer’s hard drive, including a copy of the website database file.

Save this backup or copy of your website in a new folder (folder name can be “backup-my-site”), then paste that folder in “my documents” or on the desktop.

If you made a Github clone or a download, delete the .git folder that has been automatically attached to the files unless your intention is to later upload the project to Github.

2. Copy and paste the backup into the localhost.

As you should know, the localhost allocates a folder to locate projects there. In my case, the localhost is called Xampp, and the folder for this purpose is htdocs.

In that folder, copy and paste the backup of your website. Remember to unzip it if it is a zip file, or if you made a new folder to save the backup, you must take the backup from that folder and paste it in the localhost folder with its original name (as you received it from the external host).

3. Import of the database.

Inside the backup, there is a file in .SQL format. This file contains information about the website database. WordPress requires a connection to the database to function, but that connection does not happen automatically, the connection must be done manually. Here’s how:

Go to phpMyAdmin

The localhost that you are using probably has an option, it will be just a button to click on. If there is no such button, then in the browser enter this address: http://localhost/phpMyAdmin

Create an empty database

In phpMyAdmin, click on the “databases” button. Then you will see a text field to name the new database. The collation should be utf 8, as usual, and then you must click the “create” button.

Import the database

Inside the new empty database, (you will see a notice that says: “No tables found in database”), you are going to import the old database. Just press the “import” button, an Options panel will open with a “choose file” button, select that button, the file search window of your computer will open, and from there you just have to simply go to the location of the file .SQL and select it.

The name of the .SQL file will have been added to the right side of the “Choose file” button. Now just look at the bottom right of the screen for the “Go” button and select it. A success message will appear on the screen showing your database has been successfully finished.

4. Update the connection data in wp-config.php.

Inside the project folders, which are now on the localhost, there is a file called wp-config. The connection data is stored there. Please find that document, open it in a Notepad ++ or Sublime Text type code editor, and update the data if needed. You can also change the file name to include “localhost” if you want.

Many times it will not be necessary to make modifications, but it is essential to do this verification from the beginning to avoid future problems.

 // ** MySQL settings – You can get this info from your web host ** //
 
/** The name of the database for WordPress */
define( ‘DB_NAME‘, ‘cswp-theme-1 );

 

/** MySQL database username */
define( ‘DB_USER‘, ‘Christian‘ );

 

/** MySQL database password */
define( ‘DB_PASSWORD‘, 1234 );

 

/** MySQL hostname */
define( ‘DB_HOST‘, ‘localhost‘ );

And that’s practically it! You just have to put in the browser the name of your website preceded by the word localhost. You are now ready to “do and undo” everything you want. Have fun!

—————–

We'd love to know your opinion. Leave us a message or follow us! we are on social networks

0 Comments

We have more articles and tutorials that may be of interest to you.

What Elements Cannot Be Missing in a Successful Website?

Creating a successful website requires attention to detail and a deep understanding of what users are looking for. From design to functionality, there are several elements that can not be missing in a successful website. In this article, we'll explore some of the key...

How To Improve The Loading Speed Of Your Website?

In today's fast-paced digital world, having a website that loads quickly is essential. A slow-loading website can have a negative impact on your user experience, leading to decreased engagement and conversion rates. In this article, we'll explore some of the ways you...

Highly recommended books for Marketing Management and Social Media Management:

Knowing the best books for marketing management and social media management is important for improving knowledge and skills, staying up-to-date with the latest trends and strategies, enhancing decision-making, boosting creativity and innovation, and personal and...

The Importance of Having a Website For Your Business

In today's digital age, having a website for your business has become more important than ever before. With the majority of people using the internet to find products and services, having an online presence is crucial to the success of your business. In this blog,...

How to choose the right design for your website?

Creating a website for your business or personal brand is a crucial step in establishing a strong online presence. A well-designed website can help attract and retain visitors, showcase your brand identity, and ultimately drive conversions. However, with so many...

4 Steps to Reach Your Customer

The sales funnel is one of the most influential tools today in digital marketing. It has become an icon of our time and is undoubtedly transforming an entire generation since it has been consolidated for a long time. Since the nineteenth century comes this terminology...

Pay Attention to Your Thoughts

There has been enough talk about the importance of having a positive and focused mind when confronting the different challenges of life, overcoming difficulties, or that such virtue is necessary for the quest of dreams. The scenarios can be extrapolated to themselves...

How to Give Functionality to a Button With Javascript

Javascript gives us the possibility to accessing what we call the DOM, which basically always happens because everything we do in javascript directly or indirectly infers on the HTML or CSS of the site, so there is no mystery in it. And a common way to do it is...

How to Change The Behavior of The Block Elements in HTML Tags

Sometimes when we’re working with HTML or CSS, there may be the need, depending on the design in mind, to move objects from one side to another, or to add or reduce margins, to align objects next to each other or the one below the other, etc. And as these changes are...

Social Media Tactics

We use the word "tactics" in the title because one must be tactful and not emotional when using social media for business exposure and growth. Social media in its very design is a picker and poker of vanity metrics and the desire for "fame." Did you know there are...