pre-loading
backtotop

Power Your Business with Linux VM Instances on Google Cloud Compute Engine: A Step-by-Step Tutorial

September 28, 2022

Introduction: Creating a Linux VM instance in Google Cloud's Compute Engine allows you to deploy and run your applications in a flexible and scalable environment. By end of blog, you will have a Linux VM instance running in Compute Engine and a basic web server set up on it.

Objectives:

• Create a Linux VM instance in Compute Engine

• Connect to the VM instance

• Set up a basic web server on your new instance

• Transfer your files to your instance

• Clean up resources after completion

Costs: Before starting, be aware that creating and using a Linux VM instance in Compute Engine may incur costs, including charges for the instance's resources, network egress, and storage. You can refer to the Google Cloud Pricing documentation for more details on pricing, else reach us at cssdm@quadrasystems.net to estimate.

Before You Begin:

1. Create a Google Cloud project or use an existing one.

2. Enable the necessary APIs, including the Compute Engine API.

3. Set up the Cloud SDK and authenticate with your Google Cloud account.

4. Install SSH client software on your local machine.

Create a Linux VM Instance:

1. In the Google Cloud console, go to the Create an instance page.

2. In the Boot disk section, click Change to begin configuring your boot disk.

3. On the Public images tab, choose Ubuntu from the Operating system list.

4. Choose Ubuntu 20.04 LTS from the Version list.

5. Click Select.

6. In the Firewall section, select Allow HTTP traffic.

7. To create the VM, click Create.

Connect to the VM Instance:

1. Obtain the external IP address of your VM instance from the Compute Engine section in the Google Cloud Console.

2. In console go to VM instances and in list of VM’s, click SSH in the row of the instance that you want to connect to

Set Up a Basic Web Server on Your New Instance:

1. Update the packages on your Linux VM instance by running the appropriate package manager command (e.g., sudo apt update && sudo apt upgrade for Ubuntu).

2. Install a web server software, such as Apache or Nginx, using the package manager

sudo apt update && sudo apt -y install apache2

3. Configure the web server to serve your content or website. This may involve editing configuration files, creating directories, and placing your files in the appropriate location.

4. Verify that Apache is running:

sudo systemctl status apache2

5. Overwrite the Apache web server default web page:

echo '<!doctype html><html><body><h1>Hello World</h1></body></html>' | sudo tee /var/www/html/index.html

6.   Copy the external IP of the VM instance and paste it in the browser, you should be able to see “Hello World”

Transfer Your Files to Your Instance:

1. Copy your files or website content from your local machine to the VM instance using the SCP (Secure Copy) command. For example:

scp -r [LOCAL_DIRECTORY] [USERNAME]@[EXTERNAL_IP_ADDRESS]:[REMOTE_DIRECTORY]

Replace [LOCAL_DIRECTORY] with the path to your local files, [USERNAME] with your username, [EXTERNAL_IP_ADDRESS] with the external IP address of your VM instance, and [REMOTE_DIRECTORY] with the path on the VM instance where you want to store the files.

Clean Up:

1. Once you have finished experimenting with your Linux VM instance, stop the instance to avoid incurring unnecessary costs.

2. If you no longer need the instance, you can delete it using the Google Cloud Console or the command-line tool.

Conclusion: In this blog, you might have learnt how to create a Linux VM instance in Compute Engine by setting up a basic web server on the instance, transferred your files to it, and learned how to clean up your resources.

Compute Engine provides a powerful platform for running your Linux workloads with flexibility and scalability. Explore more advanced features and optimizations for your specific use cases by referring to the official Google Cloud documentation. else reach us at cssdm@quadrasystems.net to handhold wherever needed.

More Blogs

FinOps Hub: The Smart Way to Manage Your Google Cloud Costs.
FinOps Hub: The Smart Way to Manage Your Google Cloud Costs.
Tue, May 25th 2021 8:04 AM

Cloud cost management can be a complex and challenging task, especially for large enterprises. The complexity of cloud pricing models, the need for clear spending visibility, inefficient cloud resource management, and complex metrics can all make it difficult to optimize cloud spending.

Read more 
External link
Beyond Firewalls: Build Stronger Security Teams with Quadra (SOC)NXT's Expertise.
Beyond Firewalls: Build Stronger Security Teams with Quadra (SOC)NXT's Expertise.
Tue, May 25th 2021 8:04 AM

Every click, swipe, and transaction leave a trace in the virtual realm, the battleground of cybersecurity has never been more critical. As you read this, a cyber-attack occurs every 39 seconds, leaving...

Read more 
External link
Cloud Firewall Standard: Protect Your Google Cloud Network from Advanced Threats
Cloud Firewall Standard: Protect Your Google Cloud Network from Advanced Threats
Tue, May 25th 2021 8:04 AM

Google Cloud's Cloud Firewall Standard, a fully distributed firewall service provides granular control over network traffic to and from your Google Cloud resources.

Read more 
External link
Go back