Easy Ways to Host and Build Your Website in Google Cloud Platform

Easy Ways to Host and Build Your Website in Google Cloud Platform

22 April 2021

Easy_Ways_to_Host_and_Build_Your_Website_in_Google_Cloud_Platform_01

Overview

Google Cloud Platform(GCP) is offered by Google and it is a product of cloud computing services that suddenly spikes in demand for the very framework that Google utilizes inside for its end-user items, for example, Google Search, Gmail, document stockpiling, and YouTube.

Cloud Computing is a shared pool of configurable resources such as networks, servers, storage, applications, and services that customers can use for developing and delivering their products.

In this, We will see how to host and build your web application or website on Google Cloud Platform. Hosting your website on GCP gains you many benefits as it has Cost-Saving services, High Speed, Reliability, and Unlimited Cloud Storage as per the needs.

Table Of Contents

  • Create a VM to host your website.
  • Install Apache Server in the host virtual machine.
  • Build a first web page for your website on GCP
  • Configure Cloud DNS for your Website Domain name
  • Update the Nameservers in your Domain Provider Panel.

Create a VM to host your website.

Google Cloud has the feature of hosting a secure and reliable website easily, You can do more work at less price with Google Cloud. Virtual Machines are much like our physical hardware machines but we cannot see with our naked eye. It provides the functionality of the physical computer through the cloud and can access via the Internet.

Follow the below steps to create VM for your website.

  1. Go to Google Cloud Platform Console.
  2. In Navigation Menu, Click on Compute Engine>>VM Instances
  3. Now, Click on Create to create a new instance.
  4. Enter the name of an instance under the ‘Name’ heading.
  5. Select Region and Zone nearest to you.
  6. Select Machine Configuration as per your traffic and requirements. See the below image for better understanding.
    Easy_Ways_to_Host_and_Build_Your_Website_in_Google_Cloud_Platform_02
  7. Under the Boot Disk option Select the boot disk you want to use. Here we will use Ubuntu. If you want to change the boot disk then click on change.
    Easy_Ways_to_Host_and_Build_Your_Website_in_Google_Cloud_Platform_03
  8. Click on Select to select the boot disk.
  9. In the Firewall section, Check on both Allow HTTP traffic and Allow HTTPS traffic.
    See image
    Easy_Ways_to_Host_and_Build_Your_Website_in_Google_Cloud_Platform_04
  10. Click on Create to create the instance.

Install Apache Server in the host virtual machine

  • In Navigation Menu, Click on Compute Engine>>VM Instances. You will see a page like this.
    Easy_Ways_to_Host_and_Build_Your_Website_in_Google_Cloud_Platform_05
  • Click on SSH to connect to your VM.
  • Wait for the instance to connect.
    Run the below commands to install the Apache server in your machine.
  • $ sudo su
  • $ apt-get install apache2
    Enter Y if prompted.
    Easy_Ways_to_Host_and_Build_Your_Website_in_Google_Cloud_Platform_06
  • $ service apache2 status
  • You can check whether your server is running by going to the External IP address of the mywebsite VM.
  • You will see the below page if your server is running.
    Easy_Ways_to_Host_and_Build_Your_Website_in_Google_Cloud_Platform_07

Build a first web page for your website on GCP

After installing the Apache server on your host machine. You will need to modify the index.html web page stored in the /var/www/html folder.

Follow the below steps to create your first default home web page.

  1. Enter the commands into SSH of your mywebsite VM.
  2. $ ls /var/www/html
    You will see index.html file
  3. $ rm /var/www/html/index.html
    To delete the default home web page.
  4. $ vi /var/www/html/index.html
    To create a new default home web page.
  5. Enter i on the keyboard to edit the document in vi editor
  6. Create your web page by using HTML
    See below commands and image for reference.

    <html>
    <head></head
    <body>
    <h1>Welcome to My Web Page</h1>
    <marquee>This is a simple website</marquee>
    </body>
    </html>

    Easy_Ways_to_Host_and_Build_Your_Website_in_Google_Cloud_Platform_08

  7. Press Esc, Shift+Colon then type wq to save the file.
  8. Now, Enter command $ service apache2 restart to restart the server.
  9. Again, Go to the External IP address of the mywebsite VM. Congo, You will see the below page.
    Easy_Ways_to_Host_and_Build_Your_Website_in_Google_Cloud_Platform_09

Configure Cloud DNS for your Website Domain name

  1. Get back to Navigation Menu,
    Click on Network Services>>Cloud DNS
    Easy_Ways_to_Host_and_Build_Your_Website_in_Google_Cloud_Platform_10
  2. Click on CREATE ZONE
  3. Enter zone name under Zone name field
  4. Under DNS name, Enter your website domain name that you want to host and build in GCP.
  5. Provide description if applicable(Optional)
  6. See the below image for reference
    Easy_Ways_to_Host_and_Build_Your_Website_in_Google_Cloud_Platform_11
  7. Click on the Create button.
  8. Now, Click on the Add Record Set button
  9. Select Record Reference Type as A
    And under IPv4 Address Enter the External IP address of the mywebsite VM Instance.Easy_Ways_to_Host_and_Build_Your_Website_in_Google_Cloud_Platform_12
  10. Again, click on the Add Record Set button
  11. Select Record Reference Type as CNAME.
    Enter www into DNS Name and [your domain website name] into Canonical name.Easy_Ways_to_Host_and_Build_Your_Website_in_Google_Cloud_Platform_14
  12. Click on Create.
  13. Bingo, Now click on Registrar Setup on the top-right side.
    And note down the nameservers on the notepad for future use. You will use these nameservers to point your domain to Google Cloud for hosting.Easy_Ways_to_Host_and_Build_Your_Website_in_Google_Cloud_Platform_15
  14. Easy_Ways_to_Host_and_Build_Your_Website_in_Google_Cloud_Platform_16

Update the Nameservers in your Domain Provider Panel

  1. Go to your domain provider website like Godaddy, Bigrock, etc
  2. Navigate to the DNS Management page of your domain.
  3. Update your nameservers into these fields which you have noted before.

Easy_Ways_to_Host_and_Build_Your_Website_in_Google_Cloud_Platform_17

Now, It will take approximately 24-48 hours to fully update the nameservers.

Congo, You have successfully hosted your website on Google Cloud Platform. You can install a database and other services to build or upgrade your website.

search
Blog Categories
Request a quote