Migrating a Wordpress website

From Arch Hosting Wiki
Jump to: navigation, search

In this guide, we will cover how to migrate a Wordpress website from one hosting company to another. Please perform the steps below in the order they are mentioned. Please note that while this guide is written for Wordpress websites, it will be nearly the same exact steps for almost any other CMS - including Joomla, Drupal, PHPBB, MyBB, and SMF. 

This guide may look scary - but it's actually a very simple and easy process. We mention the exact steps and include a lot of pictures to help ensure that you're never lost.

Downloading files from old hosting company

You will need to download all of the files for your Wordpress website in an archive format. To do this, log in to the control panel at the source hosting company - where the website currently is hosted at. You should then visit the File Manager, and navigate to the folder where your website is installed at. These exact steps will vary depending on the control panel your hosting company uses - for our example, we will be migrating from a cPanel based host.

I09o6Ip.png

Once you've navigated to the folder the Wordpress installation lives in, you should compress all of the files. If you are using cPanel, you need to enable viewing Hidden files in your file manager to ensure that all files will be selected.

Click the "Select All" button, and then click the "Compress" button. Click on "Zip Archive" and click "Compress File(s)".

h3xKGYr.png

Once the files have been compressed, you can close the pop-up message. Then, click "Reload" on your file manager in order to fetch the new archive file.

Next, download the archive file. For cPanel, you can do this by right clicking the file and then clicking "Download"

vjZvVxy.png

Important: Once the archive file is downloaded, you should delete it from your hosting account. This file contains sensitive information about your website that you don't want publicly accessible. 

Downloading database from the old hosting company

You will next need to download the MySQL database associated with your website. Many hosting companies offer PhpMyAdmin, which is the database management tool we can use to do this. You can usually access PhpMyAdmin via your hosting company's control panel. 

To download the database, you will need to find the database name. To do this, you should open the wp-config.php file with a text editor. You can either do this via your web-based file manager, or you can open the .zip file you downloaded to your computer and then view the wp-config.php file.

Inside the wp-config.php file, there will be a section of code near the very top of the file that will look something like this:

// ** MySQL settings - You can get this info from your web host ** //
/** The name of the database for WordPress */
define('DB_NAME', 'example_wordpress1');

/** MySQL database username */
define('DB_USER', 'example_wordpress1');

/** MySQL database password */
define('DB_PASSWORD', 'example password');

/** MySQL hostname */
define('DB_HOST', '127.0.0.1');

You will want to write down the value that is between the quotes on the line containing 'DB_NAME'. For our example, this will be "example_wordpress1". 

oHVVKYC.png

Once you've acquired your database name, you should then visit your database management tool. We will be using PhpMyAdmin for this example.

In PhpMyAdmin, you should click on the database who's name you just acquired from the list on the left:

cOtJpFY.png

Note that some hosting companies who aren't using cPanel will have you select the database name before PhpMyAdmin even launches.

Once you are on the PhpMyAdmin page for the necessary database, visit the "Export" tool inside PhpMyAdmin. This will usually be via a large button on the navigation bar. Once you are on the export page, click "Go" at the bottom of the page - you usually do not need to change any of the options given to you.

WffZ95R.png

This will download a .SQL file to your computer. Now you have everything you need to begin uploading your website to the new hosting company!

Uploading files to the new hosting company

You should now visit the Arch Hosting cPanel. You will want to identify the folder where you want your Wordpress website to live. If the primary domain on your cPanel account is the one for this website, then you should probably use the "public_html" folder. If this is for an extra domain, then see the Addon Domain wiki page for help on how to create a folder for it. If you want to change your primary domain to this new website's domain, then see our Changing primary domain wiki page.

For this example, we will assume you're uploading the files to the public_html folder. Navigate to this folder in your Arch Hosting File Manager, and then click the "Upload" button.

8XbOPRh.png

Next, select the .zip file that you downloaded previously to upload it to your cPanel. If you are migrating a large website, the upload may take a while. Once the upload is complete and the progress bar turns green, click the "Go Back" link at the bottom of the upload screen.

Right click the uploaded .zip file and click "Extract". Click "Extract File(s)" on the pop-up message.

Important: Once the archive file is extracted, you should delete it from your hosting account. This file contains sensitive information about your website that you don't want publicly accessible. 

Now that the archive file is extracted, your folder should be populated with Wordpress related files as such:

vLU0fIj.png

Creating a database on the new hosting company

Now that your files are uploaded, you need to upload your MySQL database to Arch Hosting. First, you need to create a MySQL database - you can do this easily via the MySQL Database Wizard tool in your Arch Hosting cPanel. 

Step one of the wizard is to enter a database name. This should be a one-word description of your site, such as your website name or simply "wordpress".

PAIWKxn.png

The next step is to enter a username and password. The username should probably be the same thing as your database name. If you entered "wordpress" as the database name in the previous page, enter the same value on the username field on this page.

Enter a very secure password - you can use the password generator on this page if needed. Do not enter a password you use for anything else - you won't need to memorize this password or use it often, so we recommend making it something very secure and long such as a random string of special characters, numbers, and text. It is critical for your website's security that this password is very secure.

oLbhjaa.png

You will want to write down the database name, database username, and database password in a notepad file because you will need to enter this information later.

LYb7YRZ.png

On the next page, click the "ALL PRIVILEGES" checkbox to automatically select every option on the page. Then, click "Next Step" to finish the database creation process.

Uploading database to the new hosting company

Now that the database is created, we will need to upload your website's database files that you downloaded previously. Visit PhpMyAdmin in your Arch Hosting control panel, and then select the database you've just created from the list on the left:

bZcpAEA.png

Next, visit the "Import" page and then upload the .SQL file that you downloaded previously.

3MIVmij.png

Once the import completes and you see a green success message, your database should be populated with tables as seen here:

e8a2AXr.png

Hooking up database + website

Now that everything's uploaded, we just need to tell your website to use the new database. Go back to your cPanel File Manager, and return to the folder where you uploaded your website. Right click the "wp-config.php" file and click Edit, so that you can open a web-based text editor to modify the file.

You will want to modify the following lines in your wp-config.php to contain your new database information, replacing the old database information.

In the list below, replace "DATABASE NAME" with the database name you created previously. Replace "DATABASE USERNAME" with the database username you created previously. Replace "PASSWORD" with the secure password you generated previously. The "DB_HOST" line should be "127.0.0.1". 

define('DB_NAME', 'DATABASE NAME');

/** MySQL database username */
define('DB_USER', 'DATABASE USERNAME);

/** MySQL database password */
define('DB_PASSWORD', 'PASSWORD');

/** MySQL hostname */
define('DB_HOST', '127.0.0.1');

For our example, our wp-config.php file will look like this:

define('DB_NAME', 'example_wordpress');

/** MySQL database username */
define('DB_USER', 'example_wordpress');

/** MySQL database password */
define('DB_PASSWORD', 'Aqvw!0GpXk6jEMv3ujJnYp&iqpq7QYOd68bDb0zc*[email protected]');

/** MySQL hostname */
define('DB_HOST', '127.0.0.1');

Once you've updated the database information, save the file. That's it! Your website is fully migrated. The next step is to simply switch the website from the old hosting company to Arch Hosting.

Update nameservers

You will need to update the domain's nameservers to the Arch Hosting nameservers. Please see our nameserver wiki guide for a full guide on how to do this.