Installing Apache Tomcat on Google Cloud

Here we will see how to install Apache Tomcat 8 on Google Cloud. In order to install Apache Tomcat 8 on Google Cloud, you need a VM instance. If you don’t have a VM instance then please click on below link for creating a VM instance on Google Cloud.

Creating a VM instance on Google Cloud

Assuming you have created a VM instance on Google Cloud.

1)First, Navigate to your VM instance. For navigation, the path is shown below.

Click on Navigation menu -> PRODUCTS -> COMPUTE  -> Compute Engine -> VM instances.

2)Click on SSH of respective VM instance which is shown below.

3)Once your SSH terminal is open. Execute the following command to enter in substitute user mode which is shown below.

sudo su

4)Now Execute the following command to navigate in the root directory which is shown below.

cd ../..

5)Execute the following command to create a tomcat folder which is shown below. If you want to see created folder then execute ls command.

mkdir tomcat

6) In order to run Apache Tomcat, you need a JDK. Execute the following command to install JDK.

sudo apt-get install default-jdk

7)Execute the following command to navigate in tomcat folder which is shown below.

cd /tomcat/




8)Execute the following command to download Apache Tomcat 8 which is shown below

sudo wget http://mirrors.estointernet.in/apache/tomcat/tomcat-8/v8.5.42/bin/apache-tomcat-8.5.42.zip

9)The downloaded file is in zip format. so execute the following command to install unzip which is shown below.

sudo apt-get install unzip

10)Execute the following command to unzip downloaded Apache tomcat 8

sudo unzip apache-tomcat-8.5.42.zip

11)Execute the following command to check unzip apache tomcat 8. If it showing apache-tomcat-8.5.42 means apache unzip successfully which is shown below.

ls

Steps 12, 13, and  14 are optional. please follow these steps only when you want to modify Apache Tomcat port.

12)Optional step1. If you want to modify apache tomcat port then only follow this step. Execute the following command to navigate in conf folder which is shown below.

cd apache-tomcat-8.5.42/conf/

13)Optional step2. If you want to modify apache tomcat port then only follow this step. Execute the following command to modify server.xml which is shown below.

sudo nano server.xml

14)Optional step3. If you want to modify apache tomcat port then only follow this step. Now only modify port number which is shown below. For example, you want to install apache tomcat on port 80 then modify as port=”80″ and press Ctrl+X and type Y and hit enter




15)Execute the following command to navigate in the bin folder which is shown below.

cd /tomcat/apache-tomcat-8.5.42/bin/

16)Execute the following command

chmod 700 /tomcat/apache-tomcat-8.5.42/bin/*.sh

17)Execute the following command

ln -s /tomcat/apache-tomcat-8.5.42/bin/startup.sh /usr/bin/tomcatup

18)Execute the following command

ln -s /tomcat/apache-tomcat-8.5.42/bin/shutdown.sh /usr/bin/tomcatdown

19)Execute the following command to start Apache Tomcat server which is shown below.

tomcatup

20)Now Please open port 8080. If you don’t know how to open port on google cloud please click on the following the link.
Opening port on Google Cloud

21)Now go to a browser and enter the following URL to check Apache tomcat is working or not which is shown below. If you are able Apache Tomcat default page means Apache Tomcat installed successfully.
VMExternalIP:8080

22)If you want to stop Apache Tomcat. please execute the following command which is shown below

tomcatdown




Common Problems or Mistakes

1)Please perform all steps with substitute user. please don’t forget a step 3

2)Always start and stop tomcat from a bin folder.

3)Don’t forget to open port 8080. If you have modified Apache Tomcat Port then you need to open your modified port.

4)Apache Tomcat default runs on port 8080. please don’t run any other service on Apache Tomcat.

Can I access Apache tomcat only using external IP address without port 8080?

Yes, you can access. In order to do that you just need to install Apache Tomcat on port 80. please follow steps 12-14.

You may also like...

Leave a Reply