Tomcat Setup in server
We first need to install Java, which is a required dependency.
The version of Java to install depends on our specific requirements.
I have chosen Java 17 based on my requirements.
yum install java-17-amazon-corretto.x86_64
To download Tomcat 10, use the following command
wget https://dlcdn.apache.org/tomcat/tomcat-10/v10.1.7/bin/apache-tomcat-10.1.7.tar.gz
Unzip it
tar xvf apache-tomcat-10.1.7.tar.gz
vim /apache-tomcat-10.1.7/webapps/manager/META-INF
Above command will open the file in the Vim editor for editing.
After removing lines 19 and 20, the file will look like the following.
~
~
<Context antiResourceLocking="false" privileged="true" >
<CookieProcessor className="org.apache.tomcat.util.http.Rfc6265CookieProcessor"
sameSiteCookies="strict" />
<valve sessionAttributeValueClassNameFilter="java\.lang\.(?:Boolean|Integer|Long|Number|String)|org\.apache\.catalina\.filters\.CsrfPreventionFilter\$LruCache(?:\$1)?|java\.util\.(?:Linked)?HashMap"/>
</Context>
~
~
Now open /apache-tomcat-10.1.7/conf/tomcat-users.xml file in any editor and add below Roles,Username and password.
<role rolename="manager-gui"/>
<role rolename="manager-script"/>
<user username="tomcat" password="12345" roles="manager-gui, manager-script"/>
We can start the Tomcat server by executing 'startup.sh' in the '/apache-tomcat-10.1.7/bin' directory.
cd /apache-tomcat-10.1.7/bin
./startup.sh
We have successfully set up the Tomcat server and it is now ready to use.