Install Virtualmin on GCP VM Instance with LEMP Stack

Setup Ubuntu, Nginx, PHP7 and MySQL with Virtualmin on Google Compute Engine VM Instance

Google Cloud Platform is a reliable hosting solution for websites. Specially the Google Compute Engine. It offers high performance VM instances with great flexibility and features that most regular cloud VPS providers lack. And Virtualmin is a perfect control panel to manage and administrate your GCE VM instance. You can use instructions on this page to install Virtualmin on GCP VM Instance with LEMP Stack.

Yes, we’ll be building a LEMP server on GCE. We’ll use Ubuntu as server OS and Virtualmin as server control panel. You can turn your GCE VM instance to a high performance web server with below instruction. Enabling you to host multiple websites and any PHP software on your VM instance. So let’s get right into it.

Step #1 – Generate and add SSH key pair to GCP project

This step is optional. You can safely skip and go to step #2. But this step configures easy access to your VM instance. The password authentication is disabled on VM instances by default. You can connect to your VM instance using options available at Compute Engine console. But you have to login to Compute Engine console each time you want to connect to your VM instance. This can become very annoying as time goes by. So as a solution we’ll configure PuTTY for authentication. You’ll be two clicks away from your VM instance after you complete this step (and step #3).

Tutorial: Add SSH Key Pair to Google Compute Engine VM Instance

Step #2 – Launch GCP VM Instance with proper firewall rules

What’s important in this step is setting up proper firewall rules to allow connections on ports that we’re going to use. Virtualmin will be unreachable if port 10000 is blocked by firewall. Same goes for your websites if port 80 is being blocked. While there is an easy way to allow connections on port 80 and 443 during the instance creation, we’ll create a new firewall rule set for Virtualmin and use it to allow connections on port 22, 80, 443 and 10000.

Then we’ll launch a new VM instance with that firewall rule set. Finally assign a static IP address to the instance.

Tutorial: Launch GCP VM Instance to Host Websites with Virtualmin

Step #3 – Login to GCP VM Instance with a SSH Key File

You don’t need to follow this step if you’ve skipped step #1. You can go ahead to next step and install Virtualmin since you can connect to SSH using GCP console. But root user need to have a password to login to Virtualmin. So let’s set a password for root user. Connect to VM instance SSH and change to root account with following command,

sudo -i

Then execute following command to change root password,


Now you can follow step #4 to install Virtualmin on GCP VM instance.

And for the people who followed step #1, you can complete following tutorial to configure PuTTY for auto login.

Tutorial: Login to GCP VM Instance with a SSH Key File

Step #4 – Install Virtualmin on GCP VM Instance

Your VM instance should be ready for Virtualmin now. We’ll use official installation script from Virtualmin itself to build LEMP stack on VM instance. Then we’ll install additional PHP modules that are essential to running PHP applications. We’ll finish by securing the MySQL database server.

Tutorial: Install Virtualmin with LEMP on Ubuntu 20.04

That concludes the instructions to install Virtualmin on GCP VM instance with LEMP Stack. Your GCE VM instance is now fully capable of hosting multiple websites. If you have faced with errors, please create a topic on our server administration forum. I’ll try my best to help.


Hey!! I'm Tharindu. I'm from Sri Lanka. I'm a part time freelancer and this is my blog where I write about everything I think might be useful to readers. If you read a tutorial here and want to hire me, contact me here.

Related Articles

Leave a Reply

Your email address will not be published. Required fields are marked *

Back to top button