How to move a Wordpress site between servers
Last updated: September 15th 2019
How to migrate a Wordpress site from one server to another
Our friend Erik Hanchett from Program With Erik shows how to migrate a Wordpress website from a server to Webdock. These instructions are generally applicable to most other CMS systems as well, and work as a general guide on how to move a website. Webdock has numerous Wordpress specific features however, which are also touched on in the video. If you don't want to watch the vid, please see detailed instructions below.
The advanced way: If you have shell access to both servers (Terminal access via. SSH)
SSH in to your server and go to your web root - this is /var/www/html on Webdock, but varies between hosting companies. Your Web root is where the wp-config.php file is located.
You may need to pre-pend “sudo” to these commands, or run “sudo su” in order to get superuser permissions. It all depends on your host and the environment. In many cases this is not needed if your website is in a shared hosting environment.
mysqldump -u USER -pPASSWORD DATABASENAME > mydb.sql
Where USER is the database username and PASSWORD is the database password Wordpress is using. It is on purpose there is no space between the -p flag and the password itself in this command. If you do not know these credentials, you can see them by looking in the wp-config.php file.
zip -r mysite.zip .
Congratulations - you now have a zip file with all the data you need to move your Wordpress site somewhere else.!
Now SSH in to your new server (Webdock) and go to /var/www/html
This downloads the zip file you just created on your old host to Webdock.
Unzip all your data and delete the zipfile afterwards so it doesn’t take up space:
unzip mysite.zip; rm ./mysite.zip;
Set correct ownership of files
chown -R www-data:www-data .
Import your database
mysql -u USER -pPASSWORD DATABASENAME < mydb.sql
Remember this is the username and password on the NEW server. You can see the database username and password on the main server information screen in Webdock.
Remember to delete the sql dump
Update wp-config.php with the new database name, user and password. The database host is always “localhost” in Webdock.
The simpler but much slower way: Export your database via. phpMyAdmin and use FTP to download and then upload your files to your new host.
Many hosting companies, especially cheaper shared hosting, will not provide you with SSH access so that you can run the commands to dump your database and zip up your files.
In this case you need to FTP in to your existing host and download all the files to your local machine. This is typically fairly slow - and for a bit website this may take a long time.
Some hosting companies provide a rudimentary file manager in their dashboard, and in some cases you may be able to zip up all your website files and download them directly that way. It may be worthwhile it to check for that option.
Upload your files to the /var/www/html folder in Webdock. You can see your Webdock FTP credentials on the main Server Information screen.
For your database, you would then typically use phpMyAdmin to export it. This DB management tool is fairly standard with most (if not all) webhosting companies, so you should have access to this. It is fairly simple to export a database with phpMyAdmin - just log in, click on the database name in the left-hand-side column and then click on the export tab. Just click the export buttons (the default settings are fine) and you are good to go.
To import your database again in Webdock, you would then also just use phpMyAdmin. Look for the small database icon next to your DB credentials and click it, this will take you to phpmyadmin, or just enter https://yourservername.host.webdock.io/phpmyadmin in the address bar. Log in with the DB credentials, click on the Webdock database that is automatically created for you and then click the import tab. You should now be able to upload and import your database without any problems.
Now remember to Update wp-config.php with the new database name, user and password. The database host is always “localhost” in Webdock.
Let Webdock know your site is a Wordpress site
Now that you have moved over all your files, imported your database and updated wp-config so that it is using the right database credentials, you now need to let Webdock know that there is a Wordpress installation on the server so you can get access to the built-in Webdock Wordpress management tools.
You do this by going to Manage Wordpress and start with installing WP-CLI on the server. WP-CLI is a tool which helps Webdock interact with your Wordpress installation, and it can even install Wordpress for you, if you are starting from scratch.
In this case, once WP-CLI has been installed, you would then just click on the “Save path” under the Wordpress is already installed section.
Now you can use our check updates and update functionality, and also use the Lockdown functionality. Lockdown is a way to set very strict permissions on your Wordpress website, which in our experience lowers the risk of your site being hacked, even if you don’t keep it updated by 90% or more. It is very effective.
More information on Wordpress Lockdown:
General information on how to get shell access in Webdock:
Wordpress redirecting you to an old address or too many redirects?
This is a typical issue with Wordpress where you need to tell Wordpress what the correct Site URL is. Click here for our guide on how to fix this issue.