Contents
Introduction
Migrating a WordPress site to a new hosting provider can seem daunting, but with a careful plan, proper backups and systematic execution you can minimize downtime and avoid data loss. This comprehensive guide walks you through each stage—from initial preparation to post-migration tasks—ensuring a smooth transition.
1. Pre-Migration Planning
1.1 Evaluate Current Setup
- Site Size: Total disk usage, database size, and file count.
- Installed Plugins Themes: Compatibility requirements, custom code or server modules needed.
- Traffic Patterns: Peak hours to schedule migration during off-peak to reduce impact.
1.2 Choose a New Host
Select a host that meets or exceeds your current requirements. Key criteria:
Feature | Why It Matters |
---|---|
Disk Space Bandwidth | To accommodate growth and avoid overage fees. |
Uptime Guarantee Support | Ensures reliability and prompt issue resolution. |
Server Type (Shared, VPS, Cloud) | Performance and control requirements. |
For more guidance, refer to the official WordPress hosting recommendations: WordPress.org Hosting.
2. Back Up Your Existing Site
Reliable backups are crucial. You need both the files and the database.
2.1 Back Up Files
- Access your server via FTP/SFTP or SSH.
- Download the entire WordPress directory (commonly
public_html
orwww
). - Ensure
wp-content
(themes, plugins, uploads) is fully captured.
2.2 Back Up Database
- Use phpMyAdmin or a similar tool: export the database as a
.sql
file. - Or via SSH:
mysqldump -u USERNAME -p DATABASE_NAME > backup.sql
.
See the official guide: Backing Up Your Database.
3. Set Up the New Host Environment
3.1 Create a New Database
- Log into the hosting control panel (cPanel, Plesk, etc.).
- Create a MySQL database and user with a strong password.
- Grant
ALL PRIVILEGES
to the user.
3.2 Upload WordPress Files
Transfer your site files:
- Via FTP/SFTP: upload the backup directory to
public_html
or designated root. - Via SSH:
scp -r local-folder user@newhost:/path/to/public_html
.
4. Import the Database
4.1 Using phpMyAdmin
- Open phpMyAdmin on the new host.
- Select your new database, click Import, choose the
backup.sql
file. - Execute and monitor for errors.
4.2 Using MySQL CLI
mysql -u NEWUSER -p NEWDATABASE lt backup.sql
4.3 Update wp-config.php
- Edit
wp-config.php
to reflect the newDB_NAME
,DB_USER
,DB_PASSWORD
, andDB_HOST
(oftenlocalhost
). - Ensure
table_prefix
matches your imported tables.
5. Update Domain and URLs
If your domain remains the same, skip to Section 6. Otherwise:
- In the database, update
siteurl
andhome
in thewp_options
table:
UPDATE wp_options SET option_value=https://new-domain.com WHERE option_name IN (siteurl,home)
Alternatively, use the Better Search Replace plugin or WP-CLI to handle serialized data safely.
6. Test the New Site
- Modify your local hosts file to point the domain to the new server IP.
- Browse the site, verify pages, images, forms, and interactive elements.
- Check for broken links, missing images or plugin errors in the console and PHP logs.
7. Update DNS Records
- Log in to your domain registrar’s control panel.
- Change the A record to point to the new server IP.
- Optionally update the TTL to a lower value (e.g., 300 seconds) before the switch to speed propagation.
- Monitor propagation via WhatsMyDNS.
8. Post-Migration Checklist
- Reset TTL to original value after propagation.
- Reconfigure SSL certificate (Lets Encrypt or commercial cert).
- Flush caches (server, CDN, and plugin-level).
- Test forms, search, and third-party integrations.
- Review Google Analytics, Search Console and update any IP change in security plugins.
9. Troubleshooting Best Practices
Common Pitfalls
- Memory Limits: Increase PHP memory in
php.ini
if imports fail. - Timeouts: Large imports may require raising
max_execution_time
. - File Permissions: Ensure correct ownership and permissions (
755
for folders,644
for files).
Best Practices
- Perform migrations during low-traffic windows.
- Keep old hosting active for at least 48 hours until DNS fully propagates.
- Maintain an up-to-date backup strategy: daily database and weekly file backups.
Conclusion
Migrating your WordPress site to a new host need not be a stressful endeavor. With thorough preparation, reliable backups and a methodical approach you can complete the process with minimal disruption. For ongoing guidance, explore the official migration reference: Moving WordPress. Good luck with your migration!
|
Acepto donaciones de BAT's mediante el navegador Brave 🙂 |