Move Your WordPress Website To Another Domain Or Server
August 9th 2017
How To Move Your WordPress Website?
I'm confronted with this situation quite often. The reasons to move a WordPress website are:
- Someone owns a WordPress website and change to a different web hosting provider (domain stays the same).
- Someone developed a WordPress website on a temporary domain and want to put it live on the actual proper domain.
- The WordPress website needs to be duplicated for whatever possible reason.
In this blog post I will explain how to do this in a few steps.
- In this article I describe moving a WordPress website assuming that the domain name also needs to change. If this is not the case you can ignore the steps regarding changing the domain name.
- From the screenshots I use in this post you can see that I need to make use of the DirectAdmin control panel. Possibly you're making use of a different control panel like cPanel or Plesk. Don't worry, you can also find the displayed options in these control panels.
- In case the website will be hosted on the same current server and only the domain name will be changed, this article will quite easily show how to do this.
- Don't have many experience with FTP? Go to the website of FileZilla and download this free software. It's easy to use and runs on both Windows and Mac PCs.
What do you need?
Make sure you have the following information available:
- FTP login information from both the old and the new server. You can get this information from your provider.
- Control panel login information from both the old and new provider.
- Database login information from the current database. If you don't remember this information check the config.php file in the root directory of the website to move.
STEP 1: Download files
Open your FTP client (in my case FileZilla), connect to the server where the website is located that you need to move and go to the folder where the website file are located. In most cases this is the public_html or www folder. Your screen should more or less look like this screenshot:
Download all folders and file, excluding cgi-bin, to a folder (e.g. WordPress old) to your PC by dragging the files and folders to the destination folder.
STEP 2: Export database
While you're downloading the files (this can take a while depending on the amount of files and their size) you can already export the database. Go and login on your control panel. In the screenshot below you see the main screen of DirectAdmin. In case you're making use of another control panel follow similar directions. At the end you need to end up in the phpMyAdmin screen in which you'll find the database tables.
Choose 'MySQL management' after logging into your control panel (see screenshot below).
Click on the link 'phpMyAdmin' in your next screen (see next screenshot).
A pop-up will appear in which you need to login with your database user name and password (see screenshot below).
Once you're in phpMyAdmin you need to select the database that you need to export in the left hand column before clicking on 'Export' in the top navigation (see next screenshot below).
You're now looking at a screen similar to this screenshot:
Now make sure you:
- Choose 'Custom - display all possible options'.
- Select all tables.
- Select 'Save output to a file'.
- Choose 'SQL' format.
- Check 'Display comments'.
- Choose 'structure and data'.
- Check 'Add DROP TABLE / VIEW / PROCEDURE / FUNCTION / EVENT / TRIGGER statements'.
- Check 'CREATE TABLE options:' and both 'IF NOT EXISTS' and 'AUTO_INCREMENT' options.
- Check ' Enclose table and column names with backquotes'.
- Choose 'both of the above'.
- Check both 'Dump binary columns in hexadecimal notation' and 'Dump TIMESTAMP columns in UTC'.
- Finally click 'Go' and your database will be downloaded as a .sql file.
STEP 3: Uploading files and folders
When downloading the files and folders from step 1 is finished you can login to the new server via FTP. Go to the folder in which the website needs to be placed (normally public_html or www. If you're not sure contact your provider). When there's already an index.html or index.php file located in this folder rename it to for example index_old.html or index_old.php. The same applies to a possible .htaccess file.
In case you already hosted a website on this domain remove it first (if desired make a backup by downloading the files and folders to your PC).
Now upload the files and folders of your website to the new domain by dragging it to the destination folder.
STEP 4: Database import
To make your WordPress work you also need to import your database to the new server. Login to the control panel of the new server and click on 'MySQL Management'. Then choose 'Create new Database' (see screenshot below).
Give your database a name, create or select a user, create a password and click 'Create' (see next screenshot). Note down this information as you'll need it in some of the next steps.
Login to phpMyAdmin of the new server like you did in step 2. Choose the database you just created and click 'Import' (see screenshot below).
In the next screen:
- Select the database .sql file that you've downloaded in step 3.
- Check 'Allow the interruption of an import in case the script detects it is close to the PHP timeout limit.
- Select 'SQL'.
- Check 'Do not use AUTO_INCREMENT for zero values'.
- Click 'Go' to import your database.
If you successfully imported your database you'll find the tables of the database in the left hand column.
STEP 5: Changing domain name
The database contains some data that needs to be changed regarding your new domain name. All the data that needs to be changed can be found back in the table 'wp_options'. Click on this table in the left column. Now all the rows in this table appear in the main column. On the very top you'll find the row 'siteurl'. Click on 'Edit' and change the url to the new domain in the text area field (see next screenshot). Finally click on 'Go' and the data will be saved. Normally there are at least two items that needs to be changed, siteurl and home. However there could be more items that needs to be changed. I therefor advise to scroll through all rows to check them on the old domain name.
STEP 6: Changing database information in config.php
When all files are uploaded on the new server it's time for the final step, changing the database information in the config.php file. Go via FTP to the root of your new website and look for the config.php file. In this file you'll find the follow information:
// ** MySQL settings - You can get this info from your web host ** //
/** The name of the database for WordPress */
/** MySQL database username */
/** MySQL database password */
/** MySQL hostname */
/** Database Charset to use in creating database tables. */
/** The Database Collate type. Don't change this if in doubt. */
Enter your new database name, database username and password. Usually the hostname is localhost. Other options exist, when you're not sure contact your hosting provider for the correct information. The above information I entered in accordance with the screenshot from step 4.
That's it! You now probably successfully moved your WordPress website to another domain or server.
Feel free to contact me for any questions or comments.