0% found this document useful (0 votes)
34 views7 pages

Tomcat Installation in Redhat

The document outlines the steps to install Tomcat on a Redhat EC2 server, including setting up security groups, downloading Tomcat, and installing Java. It also details how to configure the Tomcat manager and set up a proxy with Apache. Finally, it advises on securing the server by blocking port 8080 for public access while ensuring the web application remains functional.

Uploaded by

Tushar Bedke
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
34 views7 pages

Tomcat Installation in Redhat

The document outlines the steps to install Tomcat on a Redhat EC2 server, including setting up security groups, downloading Tomcat, and installing Java. It also details how to configure the Tomcat manager and set up a proxy with Apache. Finally, it advises on securing the server by blocking port 8080 for public access while ensuring the web application remains functional.

Uploaded by

Tushar Bedke
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd

Tomcat Installation in Redhat

1. Create a Redhat Ec2 Server and assign proper security group


Open Port

Http - 80 (Anywhere) and

8080 (Temporary basis and for MyIP)

2. Check if this is in REPO


[root@ip-172-31-43-74 ~]# yum list | grep tomcat

3. Install it manually in the server after confirming from your


manager
i) Go to the URL - https://tomcat.apache.org/download-80.cgi

ii) Click on Copy Link

iii) Download it in Server using wget (if it is not there, install wget)

wget https://mirrors.estointernet.in/apache/tomcat/tomcat-8/v8.5.60/bin/apache-
tomcat-8.5.70.tar.gz

iv) Move this file apache-tomcat-8.5.70.tar.gz to /etc and untar it

v) List the binary which is untar


tar xvfz apache-tomcat-8.5.66.tar.gz
vi) Try to start Tomcat but it might fail because you don’t have JAVA installed,

[root@ip-172-31-43-74 bin]# pwd


/etc/apache-tomcat-8.5.70/bin
[root@ip-172-31-43-74 bin]# ./startup.sh or sh startup.sh
Neither the JAVA_HOME nor the JRE_HOME environment variable is defined
At least one of these environment variable is needed to run this program

vii) Install Java

[root@ip-172-31-43-74 bin]# yum install java-1.8* -y

viii) Start the Tomcat


cd /etc/apache-tomcat-8.5.70/bin
./startup.sh

Tomcat starts at 8080 port by default-

[root@ip-172-31-43-74 webapps]# netstat -anp|grep 8080


tcp6 0 0 :::8080 :::* LISTEN 13799/java

9) cd /etc/apache-tomcat-8.5.70/webapps and check if ROOT and manager is present or not.


10) Try to open the manager page from Browser

http://13.234.115.11:8080/manager/

11) By Default it will blocked from remote address, so we need to update context.xml of
manager to fix it.

[root@ip-172-31-43-74 manager]# pwd


/etc/apache-tomcat-8.5.70/webapps/manager

[root@ip-172-31-43-74 manager]# find . -name context.xml


./META-INF/context.xml

cp ./META-INF/context.xml ./META-INF/context.xml-bkp

12) Update this file. Comment the Value. Take a backup before updating it using ‘cp’ command

Check the diff with original Backup


13) Now check the URL it will work and you should also update the tomcat-users.xml

cd /etc/apache-tomcat-8.5.70/conf

cp tomcat-users.xml tomcat-users.xml-backup

vim

update as below with entries here-


<role rolename="admin"/>
<role rolename="admin-gui"/>
<role rolename="admin-script"/>
<role rolename="manager"/>
<role rolename="manager-gui"/>
<role rolename="manager-script"/>
<role rolename="manager-jmx"/>
<role rolename="manager-status"/>
<user name="admin" password="adminadmin" roles="admin,manager,admin-
gui,admin-script,manager-gui,manager-script,manager-jmx,manager-status" />

14) Now restart


You can create a Soft link (Optional and Highly Recommended)

cd /etc/

ln -s apache-tomcat-8.5.70 tomcat

ls -ltr
lrwxrwxrwx. 1 root root 20 Dec 5 15:45 tomcat -> apache-tomcat-8.5.70

cd /etc/tomcat # CATALINA_HOME (TOMCAT_HOME)

ProxyPass

1) Enable Selinux Security (REDHAT)

setsebool -P httpd_can_network_connect on

2. Install Apache
yum install httpd -y

export APACHE_HOME=/etc/httpd #Command to set OS ENV Variable

3. cd $APACHE_HOME/conf.d

[root@ip-172-31-43-74 conf.d]# cat proxypass.conf


ProxyPass /SampleWebApp123 http://localhost:8080/SampleWebApp123/
ProxyPassReverse /SampleWebApp123 http://localhost:8080/SampleWebApp123/

4. List the files

[root@ip-172-31-43-74 conf.d]# ls -ltr

total 20
-rw-r--r--. 1 root root 516 Jun 15 11:49 welcome.conf
-rw-r--r--. 1 root root 1252 Jun 15 11:49 userdir.conf
-rw-r--r--. 1 root root 2926 Jun 15 11:51 autoindex.conf
-rw-r--r--. 1 root root 400 Jun 15 11:55 README
-rw-r--r--. 1 root root 139 Dec 5 08:18 proxypass.conf

4. Restart the Services and it will work

5. Block the 8080 port now for Public and you will see still your Web Application will work.

You might also like