Setup NGINX on Google Compute Engine

Hi Folks.  This article showcases how quickly one can setup NGINX server on Google Compute Engine.

Prerequisites:
A. Google Cloud Account. You can create one here.

Steps:
1. Create Compute Engine Instance i.e. Virtual Machine
2. Deploy web server on VM

Let’s Simplify

 

1. Create Compute Engine Instance i.e. Virtual Machine:

  • In the GCP Console, top left of the screen, select Navigation menu > Compute Engine > VM Instances.
  • To create a new instance, click Create. The few important parameters are
  • Name: give the name of your choice for the instance e.g. ap-gcp-instance
  • Region: Its a geographical location where you host/run your resources. In most cases select the region closest to your users. e.g  asia-south1. The region is collection of zones.
  • Zone: Each region as independent collection of zones. e.g. asia-south1-a
  • Machine Type: select the machine type as per your application need. It can be standard, highmem or highcpu or memory optimized. e.g. 1 vCPU
  • Boot disk: Its nothing but the OS for your VM. it can be ubuntu, debian, redhat or windows. e.g. Ubuntu 18.10
  • Firewall: Tick the ‘Allow HTTP traffic‘ checkbox. This will create a firewall rule to allow HTTP traffic on port 80.
  • Click Create.  Instance will get created within a minute.

ap_gcp-instance

 

2. Deploy NGINX on VM Instance:

  1. Look out the external IP and try to access it e.g. http://35.200.206.135. You wont get anything loaded in browser because we haven’t setup any webserver yet.
  2. lets SSH the to virtual machine. Click on the SSH on right hand side. It will launch a SSH client integrated in browser. (My favourite black terminal window)
  3. One done, get the root access using command

sudo su –

4.  as root user now, update OS first

apt-get update

5. Next install the NGINX on VM

apt-get install nginx -y

6. Check the nginx is running on server using below command

ps auxw | grep nginx

output

nginx-ps
showing NGINX service started

7. All Done. Lets browse the external ip now e.g. http://35.200.206.135/  You could see the default webpage showing message Welcome to nginx!

Suggestions and feedback are welcome !!!

 

2 thoughts on “Setup NGINX on Google Compute Engine

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )

Connecting to %s