Migrate Your Moodle Site to Google Cloud: Step-by-Step Guide
Migrating your Moodle site to Google Cloud moves your learning platform to a powerful and scalable environment.
This process transfers your website’s files, database, and settings from your current server to Google’s cloud infrastructure, offering better reliability and performance.
You’ll set up a virtual machine, often using Ubuntu 22.04 LTS, and then move your Moodle data over.
This guide shows you how to move your Moodle site step-by-step, covering everything from the initial setup on Google Cloud to getting your Moodle site up and running with services like Apache and MySQL.
Migrate your Moodle site by preparing a Google Cloud Compute Engine instance, exporting your Moodle files and database, and then configuring the new server environment with matching software versions. This process ensures a smooth transition with minimal downtime.
Taking inventory of a Linux server before migration
Before you move your Moodle site to Google Cloud, you need to gather important details about your current Linux server. This includes checking your web server and database server versions, your PHP setup and any needed modules, and how other servers and services are configured. Knowing these details helps ensure a smooth Moodle migration.
These are what you’ll need to gather from your current server:
- Web server and version number
- Database server and version number
- PHP and related modules
- Other servers and services and how they’re configured
If you’re running an Apache web server, use the commands below to determine what version is installed on Ubuntu Linux.
apache2 -v
For more detailed version checks and steps to install a specific version of Apache, read the post below:
How to check and install specific Apache versions on Ubuntu Linux
If running an Nginx web server, use the commands below to determine what version is installed on Ubuntu Linux.
nginx -v
For more detailed version checks and steps to install a specific version of Nginx, read the post below:
How to check and install specific Nginx versions on Ubuntu Linux
To check what version of PHP is installed and how to install a specific version on Ubuntu Linux, read the post below:
How to check and install specific PHP versions on Ubuntu Linux
Whether you’re running MySQL or MariaDB, the post below shows you how to determine which version of MySQL or MariaDB runs on Ubuntu Linux.
How to find what version of MySQL or MariaDB runs on Ubuntu Linux
How to set up and connect to your Google Cloud server
You can set up and connect to your new Google Cloud server using Compute Engine, which acts like a virtual computer. Within the Google Cloud Console, you can connect to your virtual machine (VM) instance directly through your web browser using SSH. This makes accessing your server simple and convenient.
Your Google Cloud server, called Compute Engine, lets you connect to your virtual machine (VM) instance right from your browser window within the Google Cloud Console using SSH.
SSH from the browser supports the following:
- Web browsers
- The latest version of Google Chrome
- Firefox
- Microsoft Edge
- Microsoft Internet Explorer 11 and later
- Safari 8 and later. Note that Safari in private browser mode is not supported.
- Virtual machine configurations
- All Linux VM images are natively available in Google Cloud.
Google Cloud offers all Linux VM images right out of the box, so you won’t need any extra software or browser extensions. Log in to your Google Cloud Console and navigate to Menu > Compute Engine > VM instances.
From the list of virtual machine instances, click SSH in the row for the instance you want to connect to.

You can also click an instance’s name and then SSH from the instance details page to open an SSH terminal window.
SSH commands connect you to your Ubuntu Linux instance, preparing your server to run commands. You can verify the connection by running a simple command like `ls`, which lists files in your current directory. This direct connection allows you to manage your Moodle site's files and settings on the Google Cloud server.

Install LAMP or LEMP on the new server before migration
To prepare your new Google Cloud server for Moodle, you should install a web server package like LAMP or LEMP. The goal is to make sure your new server has the same essential software and packages as your old one. Installing these packages ensures your Moodle site will run correctly on Google Cloud.
Your goal is to make sure the new Google server has all the same servers and software packages as your current one. We’ve listed some helpful posts to guide you through installing essential software like Apache (a web server), Nginx (another web server), MySQL, MariaDB (database management systems), and PHP (a scripting language).
Some other posts that you may want to use when installing LAMP or LEMP on Ubuntu Linux.
- How to install Apache on a Google Cloud server (alternative to Nginx)
- How to install Nginx on a Google Cloud server (alternative to Apache)
- How to install PHP on a Google Cloud server
- How to install MySQL or MariaDB database server
You can use the posts above to install the same servers and packages you have installed on your current server. However, install specific packages on your new server using the identical posts mentioned above.
Once all the packages are installed, you can transfer content from your current server to the new one.
Configure your new Google server similar to your current server
To ensure a smooth Moodle migration, you must configure your new Google Cloud server settings to match your old one. Pay close attention to your web server (Apache or Nginx) settings, making sure the directory structure and content of your Virtual Host or Server blocks are identical. Also, check your PHP configuration.
Make sure the web server (Apache or Nginx) settings are the same on both your old and new servers. This includes matching the directory structure and the content of your Virtual Host or Server blocks.
- Apache directory: /etc/apache2/
- Nginx directory: /etc/nginx/
Your PHP configuration should also be identical to your current server’s PHP settings. Use the post above to install a specific PHP version and all the modules on your current server.
- PHP directory: /etc/php/
Your MySQL or MariaDB configurations should also closely match your current server’s. Validate each file, directory, and other data to ensure your new server is no different from your current server before migration.
- MySQL / MariaDB directory: /etc/mysql/
Once you have that done, you can continue with the migration process.
Back up current server data and database before migration
Before migrating your Moodle site to Google Cloud, it’s essential to back up all your website files and database information from your current server. First, stop all ongoing changes to your Moodle site and its database to prevent data loss. Then, back up both your website content and your database content.
First, you need your Moodle website content and database content. Back up the website content as well as the content in the database.
Before you back up your current server, it’s crucial to stop all changes. This prevents new data from being added after the backup is complete, ensuring data integrity.
When you run the commands below, your Moodle content will create a backed-up file named current-server-backup.tar.
You must back up your database content before migrating your Moodle site to Google Cloud. Use the root account, or an account with full access to your database, to perform this database backup.
A file named `all_databases_backup.sql` is created in the current working directory to ensure all Moodle site databases are backed up. This backup file contains the complete structure and data of your Moodle databases, making it vital for a successful migration to Google Cloud.
You should now have two files: current-server-backup.tar and all_database_backup.sql.
Copy the current server’s content to the Google Cloud server
At this point, you should be ready to copy the current server’s content over to your new server. There are many ways to get the tar and SQL data files to the new server.
You can use the rsync command from the new server by SSHing into it and using a command similar to the one shown below (remember to change the host names as needed).
While connected to your Google Cloud console, run the commands below to connect to your current server and copy over the backed-up content.
You can use SCP, a secure way to copy files, to transfer your Moodle site files. The command syntax for SCP looks like this: `scp -r /path/to/local/moodle/directory username@remote_host:/path/to/remote/directory`. This secure copy protocol (SCP) ensures your data transfers safely.
scp user@old-server.com:/home/<username>/all_database_backup.sql /home/username/ scp user@old-server.com:/home/<username>/current-server-backup.tar /home/username/
If you can’t get the files using SSH, then you can use the wget command to download the files to your new Google Cloud server.
You must copy the files to the current server web server root directory to be able to use the commands below.
cd ~ wget http://old-web-site.com/all_database_backup.sql wget http://old-web-site.com/current-server-backup.tar
Once the files are copied to your new server, continue below to extract them and import the database content into your database server.
Restore the current server’s content to the Google Cloud server
After backing up your Moodle site, you need to restore the saved files and database content onto your new Google Cloud server. Use commands like tar to extract your website files and copy them to the correct directory. Then, import your database backup using commands like mysql to ensure all your data is transferred.
tar -xvf current-server-content.tar sudo cp -rf /var/www/html/ /var/www/html/
Next, run the commands below to import the database content to your servers.
sudo mysql -u root -p < all_database_backup.sql
By now, your Google server should have all the same server software and database content as your current one. Next, run the commands below to set up the current permissions to match the server.
Validate that all configurations on your current server match your new Google Cloud server. Once all have been validated, restart your web server.
sudo systemctl restart nginx sudo systemctl restart apache2
If you get an error, make sure to resolve it.
Update your DNS and point your domain to your new Google server IP address
Once you’ve successfully tested your Moodle site on Google Cloud, update your domain’s DNS records. Log in to your DNS provider and change the DNS A record to point to your new Google Cloud server’s IP address. This step ensures that when people visit your domain, they are directed to your Moodle site on Google Cloud.
Once your local test is successful, log in to your DNS provider portal and update the DNS A record to point to your new server IP address.
If everything works, you can continue fine-tuning your new server to ensure everything is configured correctly.
That should do it!
Conclusion:
This post showed you how to migrate a Moodle website to a Google Cloud server. Please use the comment form below if you find any errors above or have something to add.
Was this guide helpful?
About the Author
Richard
Tech Writer, IT Professional
Richard, a writer for Geek Rewind, is a tech enthusiast who loves breaking down complex IT topics into simple, easy-to-understand ideas. With years of hands-on experience in system administration and enterprise IT operations, he’s developed a knack for offering practical tips and solutions. Richard aims to make technology more accessible and actionable. He's deeply committed to the Geek Rewind community, always ready to answer questions and engage in discussions.
No comments yet — be the first to share your thoughts!