So you got yourself a brand new webhost but do not know how to migrate your wordpress website from your old webhost to a new one? Then do not worry because we’ll show you it here at WPisLIFE! just follow the steps below and you’re good to go.
Let’s start!
Create your Website Backup
On your old cpanel homepage, scroll down to the “Files” section and look for “Backup” and click it.
You will be directed to the Backup page, and once there we will create a full backup of your site. You will see a full backup option on that page. Look for the “Download a Full Website Backup” button and click it
When you are already there, you will see a “Generate a Full Backup” option. You will be asked to choose the destination of your backup file. You will see several choices there such as Home Directory, Remote FTP Server, and Secure Copy. Me personally, I choose Home Directory and just download it manually from the file manager once the backup is generated. You will also be asked your email address where you will receive a notification once the generation of your backup is complete. You can also choose not to be notified by by choosing “Do not send email notification of backup completion”. Once you have entered all the details, click the “Generate Backup” button then wait for several minutes while your website’s backup is being generated
If you choose to receive an email address, you will get an email from your hosting company saying that your backup file is already complete. The email looks something like this
Download the Backup File
Once the backup generation is complete, locate the file in your web hosting account by going to the File Manager and since I chose the home directory, I should be able to see it there and there it is.
Click once on your backup file, then you will notice that the “Download” text on top of your screen will be selectable. Click it to download your backup file
You can now say goodbye to your old hosting account as you already have what you need. Now we go to your new hosting account.
Point your Domain to Your New Web Host
First, we need to setup your domain to be pointing to your new webhosting’s nameserver. So just go to your name registrar account and change it. You can check this tutorial on how to edit your domain’s nameserver
Create the add-on domain
I am assuming that you will be migrating your website as an add-on domain to your new webhost. If you will be using your domain as your primary then you can disregard this step.
On the cpanel homepage, scroll down to the domains section and look for “Addon Domains” and click it
Once there, you will be ask to fill the following:
- New Domain Name – this will be the domain name of the website that you will be migrating. Enter the website without the http:// or www
- Subdomain – it will be autopopulated as your domain name without the TLD extension although you can modify it to your liking, and just for your information, your addon domains will become a subdomain of your primary domain, meaning, you can alternatively access your website thru your primary domain by using this sample url – yourdomain.example.com, wherein example.com is your primary domain.
- Document Root – this is will be the folder that will be created where your website contents need to be placed. Just like the Subdomain field, this is also autopopulated but you can also modify it base on your preference.
You can also create an FTP account by checking the box but in this tutorial, I will not make one and I will just leave it as is.
Once you have entered all the details, just click “Add Domain” and your domain will be added to your webhost
Upload your Website files
The next thing to is upload to your new hosting the contents of your website. If you remember in the earlier steps, we made a full backup of your website but in the backup file, we just need basically 2 files, the main folder that contains your wordpress files and your database, so what we do is extract your downloaded backup file and look for the following folders
- mysql – this contains your wordpress database file
- public_html – this contains your wordpress file. This folder is actually inside the folder “homedir”
Inside the “public_html” folder, you will find the wordpress files of the primary domain in your old server, as well as the folders of your addon domains (if there’s any. In my case, I have several addon domains so you can see that there are several folders inside the public_html folder that actually contains the wordpress files of my addon domains
If you are migrating a wordpress site which is an addon domain of your old hosting, you can find its wordpress content inside the public_html folder, but if you are migrating a website which is a primary domain of your old hosting, then you need to upload the whole public_html folder to your new server.
To upload, you compress the folder that you need to upload to your new server, and on your cpanel, go to your file manager and locate the document folder of the addon domain that you created earlier. Or if you are migrating it as the primary domain of your new hosting, upload the file to the public_html of your new hosting. In this example, I will be migrating the website as an addon domain to my new hosting and I will upload the files to the folder mydomain.com (the folder that was created earlier for the addon domain)
Once you have uploaded the compressed file, unzip the file inside the addon domain folder and make sure that the wordpress files and folders are placed exactly at the main addon folder (see below image for example)
You are now done with the wordpress files. The next step you need to do is to create your wordpress database and the user for that database. For creating these items, you can follow the steps on my article How To Install WordPress, and you can find it under the “Not So Easy Method”. Be sure to check it out.
Once you already created the database, the next step you need to do is to import the sql database from your old server to your new server. If you remember, we made a full backup of your website and the needed sql database to be imported is in the folder “mysql”. If you have several wordpress websites, the mysql folder will contain several sql databases and in order to know which database you need to import, you need to check in the wp-config.php the database that is being used. To do this, on the File Manager, enter the addon domain folder then look for the file wp-config.php, hover the mouse to the file and press the mouse right click then select “Code Edit”
Once you are in the code editor, look for the snippet “define(‘DB_USER’, database_name’);” “database_name” will be the name of the database that you need to import.
To import the wordpress database, on your cpanel page, scroll down to Databases then look for “phpMyAdmin”. Click it to proceed.
Inside your phpMyAdmin area, you can see on the left side of your screen your databases. In my case, I have several databases and for this tutorial, we will import the wordpress database to the database with the name “sample”. You can see in the image below that the database is still empty. To import the database, in the left hand side of your phpMyAdmin, click once the name of the database in the left to activate it, then at the top menu of your phpMyAdmin, click “Import”
After you click “import”, you will be directed to the import tab of your phpMyAdmin. There is a big text on that page that says “Importing into the database “DATABASE_NAME” where in this case it is one with the name “sample”. Make sure that the database stated in the text is the correct database where you will import your wordpress database. If you are indeed sure that this the the correct database, just browse for your database in your local computer where you saved the full backup file, by clicking “browse” then locating your wordpress database. Once you have already selected it, there is not much to edit in this page as I also just leave everything as is then just press “Go” to start the import process. Also, take note that the maximum file that you can import is only 50MB. If your file is larger than that, then it is recommended that you compress the file first either by gzip,bzip2,zip, then after that, modify the name of the database by adding “.sql” before the file extension (e.g. database_name.zip becomes database_name.sql.zip).
After clicking “Go” just wait for a while depending on how big your imported database is. Then once the import is finished, you will get this message, and you will also see on the left that the database that is empty earlier is now filled with several tables that wordpress will use.
At this point your website migration is almost done. As a brief recap, you already have the wordpress files in your domain folder and the sql database already imported to your new web host.
The last step that you need to do is to edit the wp-config.php file to configure the database name, database user and password to complete the migration process. To do this, go to File Manager and locate the wp-config.php then open it in code editor, the same process that we did earlier to determine the required database, but now we have to edit the following and replace it with new details based on the database that we created earlier:
- DB_NAME – enter here the name of the database that you created earlier
- DB_USER – enter here the username that you created and allowed to use the database
- DB_PASSWORD – enter here the corresponding password of the username
Once finished, click “Save Changes” on the upper right corner of the code editor.
At this point your website migration is now finished! You can now check by visiting the url of your website to see if it is working!
Did you find this tutorial helpful? Have you tried migrating your wordpress websites before? Share your stories in the comment section below
Leave a Reply