If you want to move your WordPress site from a live server to a local server, either for testing, development or just to have a backup, here is a detailed guide to do it effectively.
Preliminary Preparations
Before starting the migration process, it is essential that you prepare your environment. Make sure you have a local server installed as XAMPP, WAMP o MAMP. These packages will allow you to run PHP and MySQL on your local machine.
Local Server Installation
If you do not yet have a local server installed, follow these basic steps:
- Download the installer from the official website of the server of your choice.
- Run the installer and follow the on-screen instructions.
- Once installed, make sure that the Apache and MySQL services are running.
Export Database
The next step is to export the database of your live WordPress site. This is essential so that you can replicate all the content of your site locally.
Login to phpMyAdmin
To export the database, you will need access to phpMyAdmin:
- Go to your hosting control panel.
- Find the database section and select phpMyAdmin.
- Once inside, select the database corresponding to your WordPress site.
Export Database
In phpMyAdmin, follow these steps:
- Click on the "Export" tab.
- Select the "Quick" export method and the "SQL" format.
- Click "Continue" to download the .sql file to your computer.
Download WordPress Files
Now that you have the database, it's time to download all the files from your WordPress installation. This includes plugins, themes and media files.
Using an FTP Client
For this, you will need an FTP client such as FileZilla:
- Connect to your server using FTP credentials.
- Navigate to the folder where your WordPress website is installed.
- Download all files and folders to your computer.
Configuring the Local Environment
Once you have both the database and the files, it is time to configure them on your local server.
Import Database
Open phpMyAdmin on your local server and create a new database:
- Click on "Databases".
- Enter a name for your new database and click "Create".
Next, import the .sql file you downloaded earlier:
- Select the new database.
- Click on the "Import" tab.
- Select the .sql file and click "Continue".
Copy WordPress Files to Local Folder
Now, copy all the WordPress files you downloaded to your local server directory. Normally, this directory is located in:
/xampp/htdocs/your-site/
o
/wamp/www/your-site/
Update the wp-config.php File
It is crucial to set up the database credentials in the wp-config.php for your local installation to work properly.
Open the file wp-config.php in a text editor and modify the following lines:
define('DB_NAME', 'your_local_database_name');
define('DB_USER', 'root'); // or the user you use
define('DB_PASSWORD', ''); // normally empty on local
define('DB_HOST', 'localhost');
Modify Site URL
You will probably need to update the URL of your site to make it work in your local environment. This can be done directly in the database.
Change URL in the Database
In phpMyAdmin, look for the table wp_options (or whatever prefix you are using). Modify the following rows:
- siteurl
- home
Change the values to http://localhost/tu-sitio.
Verify Local Installation
Once you have completed all the above steps, open your browser and go to:
http://localhost/tu-sitio
If everything went well, you should see your WordPress site running on your local server.
Now you have a copy of your WordPress site in a local environment, ready for testing and development without affecting your live site.
