Web Server Google Cloud

Are you interested in learning how to run your first Hello World program on Google Cloud’s virtual machine? In this article, we will guide you through the process step by step. So let’s get started!

Web Server Google Cloud
Web Server Google Cloud

Creating a Virtual Machine

To begin, navigate to your Google Cloud console and click on the “Create VM” button on the homepage. Alternatively, you can search for “VM Instances” under Compute Engine and click on the option that appears. Choose a region close to your location, such as Toronto, and make sure to allow HTTP traffic. Then, click “Create” to create the virtual machine.

Installing Apache Server and Running Hello World

Once the virtual machine is ready, open it in a new window by clicking on the dropdown next to the SSH option and selecting “Open in Browser Window”. In the console, execute the command who am i to check your user information. To install the Apache server, you will need root permission. Use the command sudo su to gain root access.

Next, update the package manager by running apt update. Once the packages are updated, install the Apache server with the command apt install apache2. After the installation is complete, you can start configuring the default page of the server.

The default page is located at /var/www/html. Use the command cd /var/www/html to navigate to that location. You will find an HTML file called index.html. Open the file and replace the content with “Hello from technical potpourri”. Save the changes and refresh the page to see the updated content.

See also  Cloud Server Service Providers

Understanding Internal IP and External IP

When creating a virtual machine, both an internal IP and an external IP are generated. The internal IP remains the same, while the external IP changes each time the virtual machine is stopped and started. To reserve a static external IP address, go to the IP addresses section in the console and click on the external IP address. Then, choose the option to make it a static address.

By reserving a static IP address, you ensure that the external IP remains the same even if you stop and start your virtual machine. This allows the outside world to consistently access your application. If you don’t need a static IP address, you can release it to avoid utilizing an unused IP address.

Conclusion

Running a Hello World program on Google Cloud’s web server is a simple and straightforward process. By following the steps outlined in this article, you can create a virtual machine, install the Apache server, and customize the default page with your desired content. Remember to reserve a static IP address if you need to maintain a consistent external IP for your application. Enjoy exploring the possibilities of Google Cloud!

Leave a Comment