MDLog:/sysadmin

The Journal Of A Linux Sysadmin

Move a Wordpress Installation to a Different Server

| Comments

As you can see my blog is powered by Wordpress. I recently needed to move my wordpress installation to a different server and here are some details on how this can be done successfully. Why I wanted to move it? Well because I made so many customizations to my current theme, so when I wanted to test a new layout using a new theme I realized that this will break all my previous work. So in order to properly test this without breaking the live installation I had to move it to a development server.

In case you are moving your wordpress installation just because you are migrating servers and you will keep all the old installation details (domain, installation directory) then you don’t need to worry about this, as it is a very simple task… Just as a short reference you will need to:

  • backup all your web files

  • get a dump of your wordpress database (manually, phpmyadmin, etc.)

  • move the files to the new server

  • recreate the proper mysql user and database. Import the old database dump.

  • copy the old server web files to the new server

  • test it first, before moving the DNS.

Once you will change your DNS setting to point to the new server, all should be working properly as on the old server.

In my case I needed to change the domain (as I left the live installation running) and also to install it under a subdirectory (as on my development server I have many other things and could not install it in root directory as on live server). Here are the things that you will need to do extra from a simple move:

  • get the files and mysql database dump from the old server exactly as above in a simple move.

  • create the mysq user with the proper password on the new server.

  • now we need to change in the database dump the paths that are saved inside the database. I have opened the file containing the mysql dump and using a text editor changed all the occurrences of my previous installed domain to the new location (www.live_install.com –> www.development_install.com/wordpress). You don’t need to change every occurrence and the only ones really needed are the WordPress URI and Blog URI, but I have replaced them all because I wanted to have the links working properly, etc.

  • after this I have imported the changed database dump to the dev mysql server.the last thing needed was to change my .htaccess to reflect the subdirectory installation instead of the root directory on the live server:

1
RewriteRule . /index.php [L] -> RewriteRule . /wordpress/index.php [L]

After this I can play with my development installation without breaking anything on the live server, and I have the same installation (all the plugins, and theme customizations, etc.). Of course I could have reinstalled all the plugins on a new installation that had only my live server theme, but as you can see this is not at all very complicated. If you need to move your wordpress installation for whatever reason, I hope that you will find this information useful.

Comments