I recently took on a project involving the migration of a WordPress website from WordPress.com, which is a hosting service for WordPress.org. The client had a desire to move their WordPress site away from WordPress.com. This presented a bit of a challenge because WordPress.com doesn’t allow direct file transfers to another server using SSH commands like scp
or rsync
.
However, there’s a workaround that allows for a smooth file transfer, and I’ll walk you through it. Please note that this method is applicable if you have at least a “Business plan” since lower plans do not grant SSH access.
Let’s dive right in:
Step 1: Identify your SSH credentials
Begin by heading to your WordPress.com dashboard and navigating to Settings → Hosting Configuration. If you need more detailed guidance, you can follow this tutorial: Connect to SSH on WordPress.com.
Step 2: SSH into the target server
Now, SSH into the server where you intend to transfer your website. Open your terminal and run the following command, substituting ‘username’ with your server username and ‘host’ with your server’s public IP address:
ssh username@host -p 22
Note: make sure you’ve connected to the target server, not WordPress.com server.
Step 3: Navigate to the WordPress Folder
Assuming you already have WordPress installed, use the ‘cd
‘ command to navigate to your WordPress installation directory, for example:
cd /path/to/your/wordpress
Step 4: Delete the existing wp-content
For this tutorial, we will overwrite any existing WordPress installation, so ensure you don’t have any crucial files or data in the wp-content folder. Run the following command to delete the folder and its contents:
sudo rm -r wp-content
Step 5: Pull wp-content
from WordPress.com to your target server
Now, let’s use scp
to copy the wp-content
folder from WordPress.com to the server where we are currently connected via SSH. Make sure you are inside your WordPress folder and then execute this command:
sudo scp -r user@sftp.wp.com:/path/to/your/wordpress/wp-content .
This command will copy the entire wp-content directory from the remote server to your local directory, including wp-content itself and all its contents. Be sure to replace ‘user’ and ‘/path/to/your/wordpress/wp-content’ with the correct details. Since WordPress.com file structure is a bit unusual, finding the correct wp-content folder on WordPress.com can be a bit tricky, so consider SFTPing into the installation to verify the correct path.
Once this process is complete, export your website database from WordPress.com and import it into your new host. There are many tutorials available for this process, so I won’t go into details here. In general, you can navigate to Settings → Hosting Configuration, access PHPMyAdmin, and use the export option to export the database. Importing to your new host may vary depending on your hosting provider.
Lastly, before closing your SSH connection, ensure you set the appropriate WordPress file permissions, which you can learn more about in this guide. That’s all there is to it!