Migrating a Wordpress site to Webdock
Last updated: July 19th 2022
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.
Run
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.
Run
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
Run
wget https://mywebsiteaddress.com/mysite.zip
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
rm ./mydb.sql
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:
https://webdock.io/en/docs/wordpress-lockdown
General information on how to get shell access in Webdock:
https://webdock.io/en/docs/shell-users-and-sudo
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.
Related articles
-
Wordpress lockdown
Learn how our Wordpress Lockdown feature works and how it can help protect your Wordpress installation from hacks
Last updated: November 2nd 2020
-
Unhackable Wordpress
In this article we show how we secured a Wordpress site and made it nearly unhackable by generating a static copy of the entire website on the fly, using shell scripting and HTTrack
Last updated: January 26th 2021
-
How to speed up your Wordpress using just plugins
This article shows how to speed up your Wordpress site without having to touch any code whatsoever and just install some plugins to do the job for you.
Last updated: January 21st 2022
-
How To Secure Your WordPress Website: A beginners guide
In this guide we outline the most basic and rudimentary steps you can take as a beginner in order to better secure your Wordpress website
Last updated: August 12th 2022