Launching A GCP Virtual Machine, Installing Apache Server, And Deploying A Front-end Application On Apache Server

Author: Ayush Maggo

Introduction

In this blog, I will guide you through the step-by-step process of provisioning a Virtual Machine in Google Cloud Platform (GCP), installing and configuring the Apache server, and deploying the front-end application to make it accessible on the internet.

Prerequisite
  • A GCP account with a project set up.
  • Having basic knowledge of Google Cloud Platform.
  • You should have a front-end application ready on the VM for deployment.
What is a Virtual Machine?

A virtual machine in the cloud refers to a virtualized computing instance provided by cloud service providers. It enables users to run applications and operating systems remotely, accessing them through the internet.

Virtual machines have their own CPU, memory, network interface, and storage. They offer scalability, flexibility, and cost efficiency by enabling resource allocation on-demand.

In other terms, a virtual machine is a computing environment that utilizes software-defined hardware instead of specialized hardware.

What is Apache Server?

Apache Server, also known as Apache HTTP Server, is a free and open-source web server software, widely used by approximately 40% of websites worldwide. It provides users with a platform for hosting websites and serving web content over the internet.

Apache Server is known for its robustness, reliability, and flexibility.

Why do we use Apache Server for deploying our application?

We deploy applications and websites on Apache Server because of its web hosting capabilities, scalability, performance, and reliability. Apache Server enables us to serve web applications, handle high traffic loads, provide robust security features, and ensure efficient delivery of our applications to end-users.

Creating a Virtual Machine instance in Google Cloud Platform (GCP)
  • In the navigation menu, go to the Compute Engine section > VM instances.
  • Click on Create Instance to begin creating a new VM instance.
  • Provide a specific name for the virtual machine instance.
  • Select the region and Zone based on your requirement.
  • Choose a machine type based on your requirement.
  • Under Boot Disk, click on Change to select an operating system image, such as a Linux Distribution. You can also customize the disk size and type according to your requirements.
  • Set the desired boot disk size according to your requirements.
  • Configure the firewall settings by selecting ‘Allow HTTP traffic’.
  • Leave the Advanced options as default.
  • Now, finally, click on Create to create the VM instance.
  • The process may take a few minutes. Once the Virtual Machine instance is successfully created, you will see it listed in the Compute Engine instance list.
Install Apache Server on the Instance
  • Click on SSH to log into your instance.
  • Go to the root user in order to install any software.

sudo su

  • Now, run the following command to update the local package index on our Linux System.

apt update

  • Now, install Apache server. The command is:

apt install apache2

  • Copy the external IP of the instance, open Google Chrome, and paste the external IP. If you can see the Apache web page, then your Apache server is installed successfully.
Additional Customization on Apache Web Server index.html page

In additional customization, you can change and add your content according to your needs on the Apache Web Server default page. For that, go to the /var/www/html location and modify the content of index.html.

After that, when you refresh the page, the new content “Hello World” will be displayed on the screen.

Deploy Front-end Application
  • To deploy the application, you need to navigate to the directory path where your application is present inside the instance.
  • Move all the files of your application into the /var/www/html directory. Ensure that the index.html file is in the /var/www/html directory.
  • Now, open your Google Chrome again and enter your external IP. Now, you can see the project running on the server.

Or deploy applications using MobaXterm

What is MobaXterm?

MobaXterm is a versatile remote access and terminal tool for Windows. It enables easy and secure connections to remote servers, file transfer, and network operations. MobaXterm supports multiple protocols, including SSH, Telnet, FTP, and SFTP.

  • In order to deploy an application using MobaXterm, you need to navigate to /var/www/html in MobaXterm.
  • Then, drag and drop all the files of your application to the left side of the MobaXterm explorer.
  • Ensure that the index.html file is in the /var/www/html directory.
  • Now, finally, open your Google Chrome and enter the external IP of your instance.
  • At last, you can see the project running on the server.
Conclusion

This is how you can successfully create a Virtual Machine, install Apache Server, and deploy your front-end application in GCP.

Important links:

Happy Learning!

We use cookies on this site to enhance your user experience. For a complete overview of how we use cookies, please see our privacy policy.