Introduction
Migrating a WordPress website can be a challenging process, but it’s often necessary when you’re changing hosting providers, moving to a new domain, or even setting up a staging environment for testing. While plugins make migration easier, there are times when you might want to do the migration manually. Whether for better control, custom needs, or learning more about your website’s structure, manually migrating your WordPress site can be a valuable skill.
In this guide, we’ll walk you through the step-by-step process of migrating your WordPress site manually, from backing up your files to restoring your site on the new host.
Step 1: Backup Your WordPress Website
Before migrating your WordPress site, the first and most important step is to back it up. This ensures that you have a complete copy of your website (files and database) in case anything goes wrong during the migration process.
Key Items to Backup:
- WordPress Files: This includes everything in your WordPress installation folder (themes, plugins, media, etc.).
- Database: The database holds all your posts, pages, comments, and settings.
You can backup files using an FTP client (like FileZilla) or via your hosting provider’s file manager. To backup the database, you can use phpMyAdmin in your web hosting control panel.
How to Backup:
- Using FTP: Connect to your site via FTP and download the entire WordPress directory (including wp-content, wp-admin, and wp-includes).
- Database Backup: In phpMyAdmin, select your WordPress database and choose the “Export” option. Make sure to export it as an SQL file.
Step 2: Set Up the New Hosting Environment
Once you have your backups, it’s time to set up your new hosting environment. This includes:
- Installing WordPress on the new host.
- Creating a new database on your new hosting server.
How to Set Up:
- Install WordPress: Most hosting providers offer one-click WordPress installations via cPanel, but you can also manually install WordPress by downloading the latest version from WordPress.org.
- Create a Database: In your new host’s control panel, go to MySQL Databases and create a new database. You’ll need the database name, username, and password for the next steps.
Step 3: Upload Your WordPress Files to the New Host
Now that the new hosting environment is set up, you can upload your website files. Using your FTP client, connect to the new hosting server and upload the WordPress files (including wp-content, wp-admin, and wp-includes) to the appropriate directory (usually the public_html or www folder).
Step 4: Import Your Database
The next step is to import the database into the new hosting environment. You will use phpMyAdmin to do this.
How to Import:
- In phpMyAdmin, select the new database you created.
- Click the Import tab and upload the SQL file you exported in Step 1.
- Once the import is complete, you should have the same data in your new database as in your old one.
Step 5: Update wp-config.php
The wp-config.php file contains important information about your database connection. After moving your files to the new host, you need to update this file with the new database details.
How to Update wp-config.php:
- Open the wp-config.php file in the root directory of your new website.
- Look for these lines:
define(‘DB_NAME’, ‘old_db_name’);
define(‘DB_USER’, ‘old_db_user’);
define(‘DB_PASSWORD’, ‘old_db_password’);
define(‘DB_HOST’, ‘localhost’); - Change the values to match the new database credentials (name, user, password, host).
- Save the file and re-upload it to your new server.
Step 6: Update Your Site’s URLs (If Changing Domain)
If you’re migrating to a new domain, you will need to update the URLs in your database to reflect the new domain.
How to Update URLs:
- Access your new database through phpMyAdmin.
- Use a SQL query to replace old URLs with the new domain:
UPDATE wp_options SET option_value = replace(option_value, ‘http://old-domain.com’, ‘http://new-domain.com’) WHERE option_name = ‘home’ OR option_name = ‘siteurl’; - Also, run similar queries for the wp_posts table to replace old URLs in your posts and pages.
Step 7: Test the Migration
Once everything is in place, it’s time to test your website on the new host. Go through your site and check if:
- The homepage loads correctly.
- All pages and posts are intact.
- Media files (images, videos, etc.) are displaying properly.
- Plugins and themes are working as expected.
Step 8: Update DNS Settings
If you’re moving to a new host but keeping the same domain, you will need to update the DNS settings to point to the new server’s IP address. This is done through your domain registrar’s control panel. Once the DNS changes propagate (which can take anywhere from a few hours to 48 hours), your website will be live on the new host.
Step 9: Clean Up and Final Checks
After the migration is complete, consider the following final checks:
- Clear Caches: Clear any caches (both browser and server-side caches) to ensure the new website is being served correctly.
- Check Permalinks: Visit Settings > Permalinks in your WordPress dashboard and save your permalinks to ensure they are set up correctly.
Conclusion: WordPress Migration Made Easy
Migrating a WordPress site manually is a detailed process, but it’s also a great way to understand how your website functions at a deeper level. By following these steps, you’ll have complete control over the migration process and can ensure that everything is transferred correctly.
Remember, while manual migration gives you full control, it requires more time and technical knowledge compared to using plugins. However, this process can save you from relying on third-party tools and offers greater flexibility in handling large sites or complex configurations.