How to Migrate a Website Built In WordPress to the Localhost
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.
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
We have more articles and tutorials that may be of interest to you.
0 Comments