Migrating a WordPress website from one host to another using only SSH access can be done in several steps:
Step 1: Create a backup of your website
Before you start migrating your website, it is important to create a backup of your current website files and database. To create a backup, you can use the following command:
tar -czvf backup.tar.gz /path/to/wordpress
This command will create a compressed backup of your WordPress files.
To create a backup of your WordPress database, use the following command:
mysqldump -u username -p dbname > dbname.sql
This command will create a backup of your WordPress database.
Step 2: Download the backup files
Once you have created a backup of your website, download the backup files to your local computer using the following command:
scp username@oldhost:/path/to/backup.tar.gz /path/to/local/directory
Step 3: Create a new database
Log in to your new hosting account using SSH and create a new database for your WordPress website using the following command:
mysql -u username -p -e "create database dbname"
Replace ‘username’ with your database username and ‘dbname’ with your database name.
Step 4: Upload and extract the backup files
Upload the backup files to your new hosting account using the following command:
scp /path/to/backup.tar.gz username@newhost:/path/to/wordpress
Once the backup files are uploaded, extract them using the following command:
tar -xzvf backup.tar.gz
Step 5: Update the wp-config.php file
Update the wp-config.php file to point to the new database by editing the following lines:
define('DB_NAME', 'dbname');
define('DB_USER', 'username');
define('DB_PASSWORD', 'password');
define('DB_HOST', 'localhost');
Replace ‘dbname’ with your new database name, ‘username’ with your new database username, ‘password’ with your new database password, and ‘localhost’ with your new database host.
Step 6: Update the site URL
Log in to your WordPress dashboard and update the site URL to the new URL.
Step 7: Test your website
Finally, test your website to ensure that everything is working correctly. You can use the following command to check the status of your website:
curl -I newsite.com
Replace ‘newsite.com’ with your website URL.
That’s it! You have successfully migrated your WordPress website from one host to another using only SSH access.