The trick is in the order.
The above sentence was supposed to be the title this post. I thought better of it. A major reason for writing this blog is so that I can have a mind map or pool of knowledge I have come across in my work so I can refer back to it if I ever got stuck. I would hate to have to start pulling my hair out to remember the title of this post minutes after I had racked my brain trying to figure out why my word press installation muddled up the second it hit the live server. Plus, the final title does better for SEO. In case there is anyone out there outside myself using these resources.
There are thousands of resources out there so I won’t belabor the topic. My personal favorite is an article by WPBeginner. If you are looking for an in depth explanation on how to achieve migration from localhost to your live server then they are your guys. If like me you are familiar with the process, but you need a checklist to ensure that things are being done right, then you are in the right place. This article would only itemize steps. I will emphasize some errors that rookies and experienced developers alike make that make the experience a hair pulling affair. This article is Bare bones baby.
Step 1: Export your local Database
Step 2: Upload your WordPress Files and Folders to the directory of your Live site you want WordPress installed.
Step 3: Create a MySQL database on your Live site. Note: Your database name, database user and database password should be the exact same as in your config.php. Edit what you need to in order to get it that way.
Step 4: Import your WordPress database to your Live site.
Step 5: Change the site URL in the database of your live site
Step 6: Ensure your database details in your config.php file match the details in your SQL database.
Step 7: Visit your home page. If everything went well you should see your home page. Do not visit any other page before you carry out the next step.
Step 8: Login to your WordPress Dashboard. Head to settings. Under General settings tab, ensure your home and site URL are correct. Then go ahead and click save at the bottom. This should fix most of the URL’s that still bear your local host.
Step 9 (Optional): If you used a lot of plug-ins in your website, some of those plug-ins may still have URL errors. There is a simple SQL query you can execute to handle this. Only use this if you know what you are doing.
The below is a sample of the script you need with placeholder content wp_posts SET post_content = REPLACE(post_content, 'localhost/test/', 'www.yourlivesite.com/'); The above placeholders are defined below update TABLE_NAME set FIELD_NAME = replace(FIELD_NAME, ‘find string’, ‘replace string’); Type the below code if you have various link conflicts in your large WordPress database. Be sure to update the placeholders. UPDATE wp_options SET option_value = replace(option_value, ‘Existing URL’, ‘New URL’) WHERE option_name = ‘home’ OR option_name = ‘siteurl’; UPDATE wp_posts SET post_content = replace(post_content, ‘Existing URL’, ‘New URL’); UPDATE wp_postmeta SET meta_value = replace(meta_value,’Existing URL’,’New URL’); UPDATE wp_usermeta SET meta_value = replace(meta_value, ‘Existing URL’,’New URL’); UPDATE wp_links SET link_url = replace(link_url, ‘Existing URL’,’New URL’); UPDATE wp_comments SET comment_content = replace(comment_content , ‘Existing URL’,’New URL’); For a comprehensive list of SQL scripts to replace broken links across different media visit this post by Template Toaster |
That’s about it folks. As a parting shot I would say remember to follow the order religiously. Remember, the trick is in the order.