If you have SSH access to your source server, you can quickly bring almost any PHP/MySQL site into MODX Cloud quickly via the command line, including WordPress. This method requires basic knowledge of web servers and using SSH to connect to them.
1. Set Up a New Flex Cloud for the Destination
- The first step is to create your destination Cloud instance, using the Flex Cloud type Cloud. Once the Cloud creation is complete,
- From the Cloud Edit view of the newly created Flex Cloud, locate the internal Cloud URL that includes c****.paas*.**.modxcloud.com
- Scroll down on that page to reveal the SSH and Database (MySQL) credentials for use in the import process.
2. Connect to the Original Site via SSH
- Connect to the source WordPress website using SSH at your current web host.
- Once you change directories to the WordPress web root (
cd), enter the following command to get the original database credentials and note them for later:
3. Dump the Database
Use the MySQL CLI tool to dump the database that will be used to load into your new Cloud. You may need to switch to root privileges (
sudo -s) to get this to work:
mysqldump -p -u username dbdname -r db.sql
This will create a “db.sql” file which you’ll use to populate your DB in Cloud.
4. Sync the Files to the Flex Cloud
Using the information from step 1 above, send the files from the web root of the origin server to the Cloud using rsync while logged into the origin server:
rsync -azvvP . <cXXXX>@<cXXXX_cloud_URL>:~/www/
When prompted choose "yes" to transfer the files over.
5. Update the DB Credentials for the New Cloud
Use your credentials from step 1 above to login to the destination/new site in MODX Cloud. Once you're there, update the WordPress configuration file to point to the database for this MODX Cloud instance.
cd ~/www/; nano wp-config.php
Be sure to change the
DB_HOST definition value to 127.0.0.1.
This will open the WordPress config file in the nano text editor so you can update to point to the Cloud database. Use the credentials from step 1, above. Once done, proceed to Import the DB using the instructions below.
6. Import the DB into the New Cloud
While still logged into SSH in the destination Cloud instance from Step 5, change to the webroot directory and import the DB dump you created in Step 3 above.
mysql -u username -p database_name < db.sql
7. QA Review of the Site in Cloud
Now that you have moved the files, updated the configuration and imported the database, take the time to make sure everything is working as it should. Log in to the WordPress Admin in the destination Cloud, click around the Admin and test the site from the front end. Try editing posts or pages to ensure everything checks out and functions.
Because WordPress stores the URL of the site in the Database, in order to test the front end, you may need to temporarily update the wp-config.php to point to the Cloud URL you got in Step 1, by adding the following two lines to the bottom of your wp-config.php file, as follows.
First, open up your wp-config.php file as follows
cd ~/www/; nano wp-config.php
Then, add the following two lines, customizing with the Cloud URL from Step 1.
If you have an existing custom SSL certificate also install it now using our guide on Installing Custom Certificates
For a final check, if you know how, you can modify your local computer's hosts file to point to Cloud for the URL for a final review before actually updating the IP address at your DNS provider.
8. Add Custom Domains, Update DNS and Launch
If everything checks out OK, add custom domains to the Cloud in the Dashboard. Once done, you can update your DNS to point to the Cloud IP address. If you altered your wp-config.php file to the Cloud address, be sure to remove those lines from the wp-config.php before taking the site live. After the site resolves (test using WhatsMyDNS.net) to the MODX Cloud server, issue a free SSL Let’s Encrypt certificate (if you didn't install a custom cert already), and adjust your Web Rules as appropriate.
That’s it, your WordPress site should be live and blazing fast in MODX Cloud.