Need to move your site to a new web host? Follow these easy step by step instructions to move your site in under 10 minutes.
Backup your site
There are many ways to backup your existing WordPress site. Some include using WordPress plugins, and there are many available. Here, I’ll show you a manual way to do this using the basic tools available via Cpanel and File Manager. You could use an FTP program to download all the files, to include hidden files such as .htaccess. I prefer to compress all the files in the directory into a ZIP file, download it, and uncompress it on the new server. Steps below:
Log into your Cpanel or access your File Manager however you can. Once there, navigate to your website’s home directory and compress all the files, to include the 3 WordPress specific directories: wp-admin, wp-content and wp-includes.
Rename the compressed file to something descriptive and download the file to your local machine. You will later upload and uncompress this file onto your new host’s server
Export the WordPress Database
Export your database using the phpMyAdmin tool. Select the database that contains your websites’s WordPress files. Select the export tab in the navigation menu. Leave the default settings:
- Export Method: = Quick
- Format: = SQL
Click the “Go” button and your server will export the file and your browswer will download it to your local machine.
Once you have the file downloaded, move onto the preparing your new server to receive the files and base.
Create the WordPress Database on Your New Host Server
Before you can migrate your WordPress data to your new server, you must first create an environment for the WordPress installation. We start by creating a database on the new server using MySQL Databases function found in your Cpanel. Steps below:
- Access MySQL Databases tool in your Cpanel
- Create a new database. Give your database an appropriate name so you can easily identify it later
- Create new MySQL user and create a secure password and record the user and password information as you will need it later
- Assign the user to the database and grant the user with “All Privileges”
You now have a new database with a user account privilages. Now we move onto importing your WordPress Database into the database we just created.
Import Your WordPress Database
Access phpMyAdmin on your new host’s server and select the new database we just created in the previous step from the list of databases on the left side. Then, click on the “Import” tab at the top of the screen. Follow these steps:
- Click the [Choose File] button to select the .sql file you previously exported.
- Leave character set of the file to utf-8
- Un-tick the Partial Import checkbox if it is elected
- Ensure “Format” is set to SQL
- Click the [Go] button to import your files
Depending on the site of your database, your internship connection and speed of your server, this import process could take a few seconds toa few minutes. You will receive a confirmation once completed.
Upload The WordPress Files To Your New Host
Upload the compressed file that contains your WordPress directory to your new server using the File Manager. Extract the files. Once completed, you should have all your WordPress files and 3 WordPress directories on your new host.
Configure the wp-config.php File
Since we now have a new database and new secure user credentials, we must updated our wp-config.php file to reflect this. Using the File Manager, highlight and select Edit.
We must make 3 changes to this file in order to access the new database.
1. Change the Database Name
Locate the following line:
define('DB_NAME', 'db_name');
The db_name portion of this line will currently be set to the MySQL database name of your old web host. Change this to the name of the new database you have just created.
2. Change the Database Username
Below this you will find the line:
define('DB_USER', 'db_user');
In this line you need to change the db_user portion from the username of your old host to match the new username you have just created and granted All Privileges permission.
3. Change the Database User Password
Finally, edit the third line:
define('DB_PASSWORD', 'db_pass');
As with the others the db_pass must be updated with the new password you created for this MySQL user.
Save and close the file.
Update site URLs as needed
Will your URL be different on the new server? Did you change domains or did you move your site to a different subdomain? If so, you need to update the URLs so that WordPress will function properly. Here is two easy ways to do it.
1. Using WordPress Settings
Simply log in to your WordPress Site and navigate to settings located on the left hand side. Enter the correct paramaters for WordPress Address URL and Site Address URL. Hit save.
You may find that you can’t access the WordPress Admin because these settings are incorrect. If so, you can change the URLs directly from within the wp-config.php file. Here are the steps to do this.
2. Edit the wp-config.php file directly
- Edit your wp-config.php file using a file editor. You can do this from within the “File Manager” within your Cpanel.
- Add the following lines to the file.
define(
'WP_HOME'
,
'https://example.com'
);
define(
'WP_SITEURL'
,
'https://example.com'
);
replacing the “example.com” with your new URLs
- You can now save your changes and upload them back to your server. After that, visit your website to make sure that everything is working fine.
Update DNS settings
Be sure to update your domain’s DNS settings to reflect the server change. This means telling the domain to stop pointing to the old web host and point to the new one. This is an easy step but varies depending on where your domain was registered. Please reference your specific domain registrar’s instructions for these steps.
It will take about 48 hours for the DNS changes to take full effect.
TroubleShooting
If you experience an “ Invalid User Action “error after migrating your website to a new server or pushing your site from staging to live, do the following:
- Login to your server using FTP/SFTP.
- Navigate to the wp-content folder > themes > child theme folder (the folder will be the name of your child theme) > open/edit or download functions.php and remove the following line:
<?php if( file_exists( get_stylesheet_directory().'/jedi-apprentice/jedi-apprentice-import.php' ) && !defined('JEDI_APPRENTICE_PATH') ) {include_once( get_stylesheet_directory().'/jedi-apprentice/jedi-apprentice-import.php' );} ?>
Be careful not to remove the next opening php tag or your website will not load correctly.
- Save your changes and re-upload the file.
Important Note: These lines are only required while importing your demo data so you can safely remove them after that.
Recent Comments