Moving WordPress on an Existing Server

– Posted in: Web Design, WordPress

Wordpress logoI move WordPress websites so infrequently that it scares me when I have to do it. I literally freak out and try to find someone else to do it for me, someone who I expect should know how to do something as complex as moving a database.

Usually, when I develop a website using WordPress, I will set it in some subdirectory on the site I’m working on unless there is a server move. In this particular circumstance, I just had it buried below my root or public_html directory. I had done this one other time over the past few years, and it worked well. The only problem that I saw from that one was in my cPanel > Fantastico settings, WordPress still showed as being in that now extinct subdirectory.

WordPress Location

 

Installed Version

 

Upgrade Link

/sandbox

 

Unknown

 

Only manual upgrade possible

 

I have the unfortunate memory of deleting that installation only to find that I had now deleted my whole website. What an embarrassment. I hadn’t realized that my move and update of my server was not going to update the database of my cPanel. That is something my host would have to do. Since I don’t go to my Fantastico panel much at all, I don’t see the point in troubling them.

This weekend marked the time to move another website to the surface. In the back of my head, I vaguely remembered how to do it, but I didn’t want to mess it up, so I asked my host techies to do it for me. It took days and probably a lot of lost hair trying to move my site up to the public_html directory. I must say I was frustrated. I lost quality time waiting for this move to happen only to hear, we can’t figure out why we can’t get it to work, why don’t you give it a try? At this point, what more have I got to lose?

One thing that we, as web designers/developers have to realize is just because the techies hired by our hosts are brilliant and know how to do tons of stuff that you or I could never imagine doing on our servers, that doesn’t mean they know how to use particular software.  So, unless your techies understand WordPress, don’t waste your time, or theirs, asking them to migrate your site. They are there if you mess up the move and need a restore.

After losing another weekend waiting for a migration that took me less than 10 minutes to do myself, I decided to write of my experience and give clear instructions on how to make this move yourself. This tutorial assumes you know your way around WordPress.

This tutorial is for those who want to migrate their blog or work-in-progress WordPress website. What this means is that your blog or WIP is in a directory like http://yourwebsite.com/blog or http://yourwebsite.com/sandbox and you want that blog or WIP to be http://yourwebsite.com.  

Please note that when your domain name or URLs change, there could be additional concerns. You can move your files and database. However, there may still be residual references in your database that can cause issues with your links, plugins, or your theme display.

In some instances, you may require a search and replace be done on your database to remedy this problem. However, this can cause issues with the data serialization that some themes and widgets store in your database. To avoid that issue, WordPress.org suggests one of these two options.

  1. Only perform a search and replace on the wp_posts table. DO NOT try this if you don’t understand it.
  2. Use the Search and Replace for WordPress Databases Script to safely change all instances. WordPress suggests if you are a developer, use this option. It is a one-step process as opposed to the multiple-step procedure below.

However, there are times when that may not work… or you forget to even try it. For me, I had other hands in the mix, and therefore wasn’t sure what was left behind. Therefore I am writing this tutorial in step-by-step fashion so you can understand what needs to be done.

Follow these instructions carefully, and you should not have any problems moving your WordPress on your existing server.

  1. Do a FULL backup of your WHOLE website!

This is the most important thing to do on this whole list. Backup your WHOLE website. Everything. This includes your WIP/blog. If you mess up any of the next steps, this is going to save your butt!

  1. Log into your blog/WIP (WordPress).
  2. In your dashboard, go to the General panel.

Administration > Settings > General

  1. In the box “WordPress address (URI):”  and the box “Site address (URL):”  change the address to the new location of your main WordPress core files. These should match.  (I’ve never considered making these different and would never do so.)

For me, this was changing the URI from http://mydomain.com/sandbox to http://mydomain.com.

  1. Click “Save the Changes.”
  2. IMPORTANT! DO NOT attempt to open or view your blog right now! SERIOUSLY! I know it’s tempting, but don’t do it.
  3. Move your WordPress core files to the new location. This move includes ALL files and sub-directories found within the original directory, such as http://mydomain.com/sandbox. Most importantly, your index.php and your .htaccess files.

Moving directories

 

 I used Filezilla to do this, but you can also use shell.

  1. Now you can try to log into the site by going to http://yourdomain.com/wp-admin. (You may need to go to http://yourdomain.com/wp-login.php.)

Voilé! If you did all the steps to this point, you should be logged into the dashboard AND you should be able to see your front page! But don’t stop here! (** NOTE: At this point, my pages didn’t load and I couldn’t update plugins.  I tried to run the search and replace process above, but that still didn’t work.)

  1. If you’re like me, you use Permalinks. I would have thought that the search and replace procedure mentioned above would have fixed this, but it didn’t for me. So, instead, I went to my Permalinks panel (Administration > Settings > Permalinks ) and updated my permalink structure. It didn’t look as if it had changed from before but hit “Save Changes” anyway. What this does is realign all your URLs in your .htaccess file.
  2. In some instances, your images/media links could be messed up. I had links inside my store products. If you have this problem, there’s a handy plugin that really did nicely. It is called “Velvet Blues Update URLs.” You can also try the search-and-replace script, or manually in your database.
  3. There are some cases where you might need to change your permissions. I didn’t. But if you do, make sure you change them back to 0644.

This process took me all of 10 minutes to do! You can do it too.

The most important things to remember is to back up your website and change your URI locations BEFORE you move your files! It doesn’t matter if you think you can do it without a backup. Save yourself a headache and take a few extra minutes to run it. You can always delete it later.

Good Luck!

0 comments… add one

Leave a Comment

This site uses Akismet to reduce spam. Learn how your comment data is processed.