From the Inbox: Moving a WordPress Site
Morten Rand-Hendriksen
AI & Ethics & Rights & Justice | Educator | TEDx Speaker | Neurodivergent System Thinker | Dad
In this issue of #FromTheInbox, Carmen has a question we've all wanted an answer to at one point or another:
I've built a WordPress site on my computer using MAMP. How do I move it to my web host and get it online?
The answer to this question is the same whether you are moving a site from a computer to the web, from the web to a computer, or from one location on the web to another.
Application + Database + Files
A WordPress site comprises three main components: The application itself (WordPress), the database that contains all written content, relationships, settings, and references, and the files that have been uploaded to posts, pages, and the application (typically images and documents).
To move (or "migrate") a WordPress site, all three of these components need to be moved, and each of them has its own special procedure:
1. WordPress Itself
WordPress is just an application. Thus you don't have to move WordPress itself, you just need to install WordPress at the target location. I like to set WordPress up completely and publish a test post to make sure everything works, but that's not strictly necessary. Once the move is complete, whatever you post on the new site during initial setup will be erased, so as long as you're able to log into the admin panel, you're good to go.
2. The Database
The real challenge of moving WordPress is migrating the database. You can't simply export the database from one location and import it to another because every hyperlink in the database (and trust me, there are thousands even in a small site) needs to be rewritten to match the folder structure and URL of the new location.
This rewrite process requires quite a bit of finesse, and is not something you should take on. Fortunately, you don't have to: There are tools that do the job for you.
My personal preference is a plugin called WP Migrate DB Pro, which allows you to link two WordPress sites together and perform a one-click migration over the web. There is also a free version of the plugin available, called WP Migrate DB, that provides the same automated rewriting functionality, but requires a manual export/import of the database to work.
For a complete rundown of how to move your WordPress sites with WP Migrate DB / Pro, check out my Lynda.com course Moving WordPress with WP Migrate DB / DB Pro.
Other popular plugins that perform much the same operation include Duplicator, and WordPress Move, and there are several more providing general migration or dedicated migration to a particular hosting platform.
If you want absolute control, or plan on doing some more complex database rewrites, there is also the PHP Database Search/Replace tool from Interconnectit. I've used this tool several times, and it works great, but it relies heavily on your own understanding of what's going on, so for simple migration, one of the above listed plugins is far easier and safer.
3. Files
The last piece of the WordPress move puzzle is the various files that make WordPress and its content tick. These include your plugins, themes, and uploads, all found under the wp-content folder.
Once the database is migrated, you can simply transfer these files through SFTP or other file transfer means, replacing the wp-content folder on the target site in the process. More than likely, the Uploads folder will hold thousands of files, so this process can take quite a bit of time. Keep that in mind as you start your move.
Testing, Testing, 1, 2, 3...
Having successfully moved the three components above, you should have an exact duplicate of your site in the new location. At this point it is vital to test everything to make sure all your settings are working and your content is where it should be. Click on menu buttons, links, and archives and check that they lead to the right places and display the right content.
Caveats
Thanks to plugins like WP Migrate DB Pro, moving WordPress sites is a straight-forward process that rarely causes issues. That doesn't mean it's perfect though. Errors happen, and when they do it's important to keep a cool head and troubleshoot the issues in a systemic way.
From my experience, the most common problem that occurs when a move is attempted is that the wp-config.php file on the target site gets overwritten by wp-content.php from the origin site. This will cause WordPress to look for the database in all the wrong places, and the site won't work. It's an easy fix though: Simply enter the correct database name, username, and password in wp-config.php on the target site and everything will work properly.
Another common issue is that the database prefix on the target site doesn't match the origin site. Here again you can fix the problem in wp-config.php by altering the database prefix values to match.
A third and final issue is that image files are not showing up. This is typically caused by a faulty file transfer (fixed by uploading the files again), but can also be the result of having moved the uploaded files to the wrong place. If this happens, check to make sure your folder structures match between the two sites. If they do, you should be good to go.
Move Your WordPress Sites with Confidence
All this said, WordPress Migration is a simple and straight-forward process anyone can undertake with confidence. By using a plugin like WP Migrate DB Pro, and following proper migration procedures and checklists, you'll get your site moved without hassle or worry.
To get started, check out my Lynda.com course Moving WordPress with WP Migrate DB / DB Pro and become a master at the ins and outs of WordPress migration!
Hey, Morten: I want to ask a question!
From the Inbox is a semi-regular column where I answer questions from people like you. Have a question about WordPress, web development, web design, information philosophy, or some related topic? Leave it in the comments below and follow the #FromTheInbox hashtag to see if I pick your question as the basis of a future article. Though I can't answer all questions, I will try to cover those most frequently asked.
--
Morten Rand-Hendriksen is a Front End Web Development Teacher, Speaker, Workshop Trainer and Author specializing in web standards and WordPress. He's a full time Senior Staff Author at Lynda.com with more than 60 courses in the library. You can watch all his courses at Lynda.com/mor10, find him on just about any social media network @mor10, and read his personal musings on his blog at mor10.com.
Wordpress | Ecommerce | Photo Editing
8 年nice:)
Supply Chain and Business Transformation Leader | Innovation, Sustainability, and Operational Excellence | Process Optimization | Value Creation | Strategic Growth
8 年Thx
Duplicator has worked very well for me. Most of the times it works perfectly, sometimes I only need to fix some broken links, but all things considered, it is a breeze.
Team Lead - UI-UX Developer
8 年Thanks a lot, good post for WordPress developer