Running WP 3.5.1 on a LEMP stack (over at Linode) ...

I have a wp-content folder for a WP site along with a full backup of the database. The URL of the site was something like:


I want to get the site operational on my own server at:


And once the site is finished and DNS changes take effect, I want to have the site URL be:


What is the preferred (and hopefully most straightforward way) of handling server moves and domain changes like this? I'm looking for a step-by-step answer, one that accounts for all the situations described above for both the files and database.


7 Answers 7


There's a pretty good step by step on moving WordPress in the Codex. It is what I follow when changing domains.

Moving the files is pretty straight-forward. It is the hard-coded references in the database that are tricky. However, serialized search and replace will take care of all database changes. I've used the Velvet Blues plugin in the past, but the Search and Replace script is pretty top-notch.

  • Yup, that is the exact one I linked to for serialized search and replace. It is pretty much aces all around and makes moving the site super easy. Commented Feb 24, 2013 at 3:43

I utilize the awesome plugin Duplicator to complete this exact procedure on a regular basis.


The plugin is fully supported and there are great FAQ available here:


The plugin will create a .zip backup of both your database and files and an installer .php that you will put into your new root directory. You simply enter your new database information and it does the rest.

Is probably my favorite WP plugin to date.

If you need help along the way, just let me know.

  • I use this plugin ALL the time for clients sites, I can make exact copy of there WordPress and install it on my Dev server, make my changes and then make exact copy back to there server if needed
    – JasonDavis
    Commented Mar 2, 2013 at 17:11
  • Yep, I do the exact thing. This, paired with the Dropbox backup plugin (if I could actually get it to work 100% across client sites), life is good.
    – cunningfox
    Commented Mar 2, 2013 at 20:50

You will have a few things to consider (later on the answer), I suggest the following steps:

Backup your Files and Database

This is pretty self-explanatory. You are going to do a lot of Data Manipulation, so be sure your original is safe.

Transfer your files

The fastest way to do this is to have a hoster where you can import directories from another server. This can be done by providing the FTP-details, as well as defining the targetdirectory.

As Servers have a internetconnection that is usually a lot faster than the one that users have, this is the preferable way to transfer the data. You can also use your command line to execute those commands by hand.

The slower option is to generate a ZIP-file, download, upload to your new server and decompress it. If you do not have the possibility of doing that, take the slow path - donloading everything and uploading everything. And go for coffee while the files transfer :)

Transfer your Database

Again, a lot of hosters have the option of importing an existing database into a new one, even from another server (of course, your old server has to accept external data connections).

If you can do this, great, but you can also export/import your database.

Set the new (Sub-)Domain to your new directory

On your new server, be sure your Files are set up the same way as on the old one, and point your subdomain to the same directory it did on the old server (usually the WordPress root)

Edit the wp-config.php

Save the new wp-config.php. You just have to edit the Database Connection details.

Load the new URL

WordPress should be set up by now, but it still uses the old SiteURL and AdminURL, so you won't be able to log in. Change those Values in the options-table in your new Database. The two Values you are looking for are siteurl and home. Place your new Domain there.

Check your Login and your Site

Now everything should work so far, you can login, edit and write, as well as use the site. The only Problem may be that your Posts still have the old URL for the images and attachments in them.

If your Posts contain the old URL, or if you are not sure, check your database in your posts-table.

You can do this by searching your Database directly, or using a Script like Serial Search and Replace. If you find your old URL, you will have to replace it manually or automatically. I prefer doing it automatically and checking for errors afterwards.

Check the other tables

Also check if your other Tables contain the old URL. This may be a bit tricky to replace, but it also has to be done to move your site completely.

Regenerate your Permalinks

Just to be sure, save your Permalink Settings again to create the Permalinks again.

Check your site

Please, do not forget to REALLY check your site after you transferred it. Check all the functions, especially AJAX-stuff, Contactforms, Maps, etc. as they are more likely to fail than plain PHP/HTML.

Time for Beer :)

Things to watch out for!!

As always, nothing that was created manually, transferred manually and edited automatically is failproof. Here are a few commen traps that are easy to step into, but can also be avoided easily.

  • Badly coded Plugins (Saving your Website URL instead of the relative Path and using the WordPress Functions to retrieve the full URL. There can also be a lot of Problems with your AjaxURL.)
  • Encoding Problems (Be absolutely sure that you use the same encoding on both your Servers and Databases!!! Usually, if you go with the recommended UTF-8, this should be okay)
  • Serialized Data (This is the biggest Problem you may encounter. If you use a Plugin like Tablepress, where an entire Table is stored in a serialized Array, it will break as soon as you automatically replace something. If you have Data like that, look for an export/import function in this specific Plugins, and use this as an extra step. If they do not have this function, you have to do it by hand)
  • Server Settings (It can easily happen that your Site does not run on your new server due to standard settings. Be sure to have enough resources available!)
  • Hardcoded URLs in your Theme (although this should not happen, it happens far too often and breaks your Images and Links as soon as the old site is not available anymore)
  • Caching Problems (Do not use the same Caching Files as you did on your old server. The best way would be to deactivate the caching before exporting the site, as well as empty all cachings)
  • Assuming everything works when you change the settings for the second time on your server (always check everything again)
  • Options in your Plugins and Theme (Old Emailadresses etc.)

That should be it. It looks like a lot to do, but actually most of it runs automatically. You just have to think about everything that CAN go wrong, and check if it did :)

Have Fun!

  • Great write up, Time for beer should be in the Codex!
    – brasofilo
    Commented Feb 26, 2013 at 14:54

There is no need to use any plugins, scripts or even knwledge of sql. Simple notepad is enough to migration. You have to upload your all wordpress files to your new server and just change in your wp-config.php (in your main wordpress folder) 3 values: define('DB_NAME', 'your_new_db_name'); define('DB_USER', 'your_db_username'); define('DB_PASSWORD', 'your_db_password');

Next, if you are using some mysql client like phpmyadmin on your current server, you must export your database to file, then open your_db_dump.sql in notepad, then find and replace all occurencies test.example.com with test.mydomain.com after that you have to import that db_dump to your new database (which you defined at wp-config.php). Thats all.

  • Simple search and replace will fail almost 99% of domain moves because part of the data, specifically widgets, is serialized and you need to adjust string sizes as well as content. Commented Feb 26, 2013 at 6:18
  • I must not agree with You. I moved a lot wordpress installations with this method and it has always worked. In database almost all replaces are made with posts guid. Only few replaces are made in wp_options (like siteurl,home). I can agree that some data is serialized, but its not applicable for our domain url. Properly designed widget use bloginfo('url'); not direct url, so we must not care about serialized data.
    – bigwolk
    Commented Feb 26, 2013 at 10:29
  • yes, if you plan in advance or just lucky it might work, that is why I said 99% ;), but the question is a general one. And this is from my own experience. Commented Feb 26, 2013 at 10:42
  • So we have different experiences ;) I would said that this method WILL work in 99% of cases. Maybe Im wrong, because Im working on wp just for few years, but I don`t meet any resistance during moving wp, even with plugins and widgets enabled.
    – bigwolk
    Commented Feb 26, 2013 at 10:54
  • guess it depends on what you use on the site. my bad experiance was with simple sites... The thing is that as @helgatheviking has pointed there is a free tool that do the search and replace and take into consideration serialization so there is no need to gamble even if you are 99% sure you will win. Commented Feb 26, 2013 at 11:02

What I do is:

  1. Create a new database on the receiving host. Import the SQL file. Run the following SQL queries on the new database:

    UPDATE wp_options SET option_value = replace(option_value, 'test.example.com', 'test.mydomain.com') WHERE option_name = 'home' OR option_name = 'siteurl';
    UPDATE wp_postmeta SET meta_value = replace(meta_value, 'test.example.com', 'test.mydomain.com') WHERE meta_key = '_menu_item_url';
    UPDATE wp_posts SET guid = replace(guid, 'test.example.com','test.mydomain.com');
    UPDATE wp_posts SET post_content = replace(post_content, 'test.example.com', 'test.mydomain.com');
  2. Upload the WordPress files to the receiving server.

  3. Upload the wp-content folder, overwriting the default WordPress files.
  4. Set up your wp-config.php as normal, using the db name, user and password from the database you created.
  5. Go to the Dashboard, and manually change any instances of test.example.com in widgets (these can't be changed via SQL query because they are serialized in the database).
  6. When the time comes to switch to myclientsdomain.com, perform the above SQL queries and widget fixes again.

Depending on your theme and plugins, you may have additional changes to make in the database or Dashboard. These will have to be discovered yourself and changed as you find them.

Fair warning that it's not perfect and it can be a pain in the butt to move WordPress across domains. Another thing I have also seen done is to add the following to your wp-config file:

define('WP_HOME','http://'. $_SERVER['SERVER_NAME']);
define('WP_SITEURL','http://'. $_SERVER['SERVER_NAME']);

This will help the site work on whatever domain it is currently on, but you will still need to deal with hard-coded URLs in content, options and menus. I have not tested that myself and don't know if you need to remove the corresponding options from your database in order for them to work.

Update: I should have guessed there would be plugin to handle the database portion http://wordpress.org/extend/plugins/wp-migrate-db/

  • 2
    I seriously recommend NOT doing the SQL update commands suggested above. The options table specifically can contain a lot of serialized data - simple search/replaces on serialized data will corrupt that data
    – eddiemoya
    Commented Feb 20, 2013 at 1:06
  • I suggest removing that part of your answer entirely, and in fact warning against manual search/replace techniques such as that one or using the 'sed' command.
    – eddiemoya
    Commented Feb 20, 2013 at 1:07
  • I am not doing a simple search/replace. I am limiting the commands to change fields that do NOT contain serialized data, and in fact mention not using such commands on to change information stored in widgets since that data IS serialized. On the options table specifically I am using the where statement " WHERE option_name = 'home' OR option_name = 'siteurl';" to avoid changing serialized data. Commented Feb 20, 2013 at 1:33
  • I see that now, I missed the WHERE clause the first time I read it. Sorry about that. However, you shouldn't need to change the home and siteurl values in the options table, thats what using WP_HOME/WP_SITEURL does. Using those definition overrides the options table values, adding the additional WP_RELOCATE definition causes the first two to overwrite the settings in the options table.
    – eddiemoya
    Commented Feb 20, 2013 at 2:00
  • Also, I'm fairly sure that your not supposed to change the guid's in the post table. Those are not meant to be used as URL's but rather unique ID's. Edit: Looked it, up - for attachments theres a case where you need to change the guid but it doesn't apply to a straight forward domain change.
    – eddiemoya
    Commented Feb 20, 2013 at 2:04

A previous answer had this, but here is a step by step with some other input:

  • Do not install WP
  • Ftp entire original WP directory to new directory (see below if missing anything)
  • Import the sql with phpmyadmin at your server control panel.
  • Ftp searchreplacedb.php to directory WP is in.
  • Run searchreplacedb.php from your browser (delete after!!!)
  • Take some time off and bill your client $75!

    (searchreplacedb.php is available FREE at: interconnectit.com/products/search-and-replace-for-wordpress-databases ... they have instructions too).

If all you have is the WP contents folder you have another issue. You must get the rest of the WP install of the EXACT SAME VERSION. Search the db if you don't know what version WP is. It is easy to download old versions online. Get it all in the right place as before, all using ftp to set the new folders up, if you want it to just pop up as it looked before. Do not visit the site after uploading the db and WP stuff if you are missing anything or it will default to the stock theme or turn plugins off. I've lost plugin settings and had to do it all over so just think and go slow.

If you already have a sub folder or addon, or the new site will need one, plan ahead. Don’t just replace the url before taking into account the needed new folder or lack of new one. You might need to run searchreplacedb for 'folder/url' before going back for 'url', etc. Otherwise you might mess up an 'addon' changing to a 'root display with sub directory install' or other such nonsense!

If the new structure matches the old structure and you have the whole WP directory you can do it easier and faster than reading this post! Put the program in the same directory you have WP uploaded to for best results, as the instruction say, as it has an autoconfig.

If you do not have ftp access or controlpanel access or sql access you really need a better server and might be out of luck.

Try the search and replace recommended in other posts and if you are lucky, have an older version of WP and it fits into the needed parameters it will work; a real pain of a way to play Russian roulette with your site.

Also, don't ever edit data in notepad unless you know there are no strings longer than it will accept. Now there's a nice error you may spend weeks looking for! If you have to look at it, only look, don't save it. You should forget notepad exists and use notepad++, but manually editing serialized data in a text editor is as bad as trying to do a find and replace in phpmyadmin; don't do it.

You could search "sql serialized data". The short answer is that find and replace will pie serialized data in an sql. WP db’s have serialized data…more so nowadays.

I did this too many times and had marginal success and beat my head on a wall many times before I finally researched it properly. It is now a walk in the park.


I've moved a number of sites from one server/domain to another in this way, and all you usually need is a backup and your wp-content folder, which you seem to have. Here's the method I follow:

  1. Install Wordpress on the new site. You can use any method you like for this, some hosts offer one-click installs, otherwise just go ahead and do this as per your preferred method.
  2. Overwrite the wp-content folder with the copy you have. This ensures all your plugins, uploaded files etc are per your older server.
  3. Overwrite the database with the copy you have. I usually do this using phpMyAdmin with the Import facility. One thing to watch out for here is that if your backup doesn't include DROP statements you'll need to delete all the tables in the database first.
  4. If you're changing the domain name, you'll need to Browse your wp_options table in phpMyAdmin and update your "site_url" option. There's another option called "home" that you can update, but you don't have to do this as this can be changed in WordPress admin once your site is operational.


This should be all you need to do to get your site up and running. Once it's operational it would be prudent to check any plugin/theme specific settings that may reference your old site and regenerate your permalinks.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.