How to move existing WordPress site to another server

How to move existing WordPress site to another server

Some experienced developers would say: “Piece of cake , I can do it for about 15 minutes!”
But, is it really so easy and trivial task?

It’s not so heavy, but you have to pay attention on some really important things and because of that, I would like to say that it is not heavy but more sensitive task to do.

So, let’s start with article.

Imagine this situation:
We have one live site on with fully functional WordPress installation, many articles, plugins installed on the site. Let’s say that current database is bigger than 500 Mb. We have access to control panel, ftp and also ssh on live server.
Now we want now to copy same WordPress installation to (into sub-domain of new domain on new server).

Why did I mentioned SSH?

Because I don’t want to download database file and then upload it again on new test server but I want to transfer whole data without downloading it.
(Of course, in this case we must have ftp and ssh access to new server also).

TIP: For those that never used SSH before, I would advice that use Google for basic UNIX terminal commands, because they would need them. 🙂

First of all, we have to back up live site (just in case something goes wrong) and also we can use backup to transfer both database backup and files backup to new server without problems.
Often it could be done through control panel of live site. If not, there are alternatives, but I will talk just about first mentioned case for now.

When backup of whole site is finished, copy that ‘somefile.tgz’ backup file into public folder either from control panel or from some root ftp access so we could download that file via URL (for example: (Do not forget to delete it after transferring!)
Next, we have to connect by SSH to new server with our credentials (I often use Putty for SSH access because it is relatively simple, but there are more tools available for free).
Fire up Putty and enter basic connection information in sessions category: Host-name / IP address of server we will connect to and press ‘Open’ button to start the session.

If all went right you should see console like this:

Now it’s time to do some UNIX stuff.
First we want to choose our folder on server where we will host out new wordpress installation. (Using comands “cd”, “ls” will give us that possibility).
Next, we need to is ‘download’ that backup file from old server to new. We can do it with “wget” command in terminal.

After that we want to decompress our downloaded backup package and move site files from inside unpacked folder to our sub-domain directory and also extract our sqldump file so we could restore it on our mysql database on new server. (I didn’t mention that we should first create mysql database and assign a database user with root credentials to it and one of the easiest possibilities is to do that through control panel of new site).
For file decompressing you can use ‘tar -zxvf yourfile.tar.gz ‘.

Because I went too deep in details, let’s back to main theme.

After these ‘few’ steps, we should ensure that all is on it’s place, so finally we should finish with folder structure like this:

here should be out wordpress installation (index.php, .htaccess, folders wp-content etc.)

(By the way, folder ‘html’ is in our case root domain public directory and folder name portal is our sub-domain folder where points to). Why is this important? Because of .htaccess setup later in this article.

Next we should replace all occurrences of ‘’ with ‘’ in our sqldump file.
First time I tried to do that with ‘nano’ text editor in SSH terminal, but database was too big for that editor, so Putty and SSH connection crashed every time and I decided to take advantage of another tool in terminal, so I used ‘vi’ editor for that purpose because it won’t load whole file in memory, just visible part so terminal wouldn’t crash.
(Use Google to search for ‘find and replace with vi’ tutorial).

After replacing domain names in sql dump file save it and exit vi editor.

So, now we have files of site on right place and also sql dump file ready to restore to new database.
(of course while ‘vi’ editor is open we should probably add line on top of existing sql statements: USE new_database_name; )

Let’s Google again for instructions how to restore sql dump file to mysql using console. There are plenty of tutorials doing that.

When restoring database is completed we are almost ready to start our transferred wordpress site.

Open up your browser and try to enter to wp-admin:,
log in with old site credentials and check general settings for updating URLs of the site. Also check permalinks settings and save it again.
If new wordpress site is not working or displays only frontpage and not other pages in menu, probably is some problem with rewrite and / or permissions in .htaccess file. So in that case – delete .htaccess file or rename it via ftp and go to wp-admin – > settings – > permalinks again and save it again and new .htaccess file will be created with some wordpress lines.
From my experience because our installation was in root domain before and now is on subdomain,
we need to add subdomain folder name before /index.php in .htaccess file (like on image) and all should be OK.

Maybe there are easier ways to move site, maybe there are better ways, but I felt that I have to write about that from my experience before, so thank you for reading :-).

You made it all the way down here so you must have enjoyed this post! You may also like:

Adding gallery tab to a CMS page Antun Martinovic
Antun Martinovic, | 5

Adding gallery tab to a CMS page

TWIG with WordPress part1 Darko Goles
Darko Goles, | 1

TWIG with WordPress part1

Unit testing with Zend framework: Setting up environment for the first test using Netbeans IDE for php Darko Goles
Darko Goles, | 1

Unit testing with Zend framework: Setting up environment for the first test using Netbeans IDE for php


  1. Find and replace is all well and good for taking care of the hard coded URL’s in the database however there is then the problem of serialised strings that some plugins and settings will use to store information that contains the current url.
    For example “” would be {s:12}
    But then “” should be {s:15}
    Ultimately without taking care of these also then anything using it, such as Contact Form 7, will break.

  2. It is amazing to me that after all this time wordpress still adds so many hardcoded urls into the database. Why! thats like so 1996.

    good tutorial btw

Leave a Reply

Your email address will not be published. Required fields are marked *

You may use these HTML tags and attributes: <a href="" title=""> <blockquote cite=""> <code> <del datetime=""> <em> <s> <strike> <strong>. You may use following syntax for source code: <pre><code>$current = "Inchoo";</code></pre>.

Tell us about your project

Drop us a line. We'd love to know more about your project.