Apache Tomcat is an one of the open-source webserver. Steps to install the tomcat in the Ec2-instance: 1. Need to create the ec2-instance(...
Steps to install the tomcat in the Ec2-instance:
1. Need to create the ec2-instance(redhat os),
2. Install the Java,
3. Download the Tomcat package and create the link for start and stop,
5. Adding the tomcat-users, password and roles.
Installing the Java:
To install tomcat need to download the source code from the official tomcat documentation.
Use the below link to download the .gz or zip file from Official Tomcat documentation.https://tomcat.apache.org/download-80.cgi To download from Linux using the wget command, if the wget package not installed on your machine, you need to install using the below command. Command: yum install wget Now, we can download the tomcat source code inside the ec2-linux machine using below command.
Command: wget https://dlcdn.apache.org/tomcat/tomcat-8/v8.5.82/bin/apache-tomcat-8.5.82.zip
Once the Compressed file downloaded we need to Unzip the compressed file using below command.
Command: chmod +x startup.sh
chmod +x shutdown.sh
chmod +x catalina.sh
Now we can start the script by running manually by sh startup.sh or else we can link that script as executable one, for that we need to execute the below command.
Now we can start simply using the tomcatstart command as well to stop using the tomcatstop command.
Now, we can check running status by entering the http://publicip:8080 in the browser, before that make sure to add the 8080 port inside the AWS security group’s inbound rules.
To fix the above error, you should need to edit the manager’s context.xml file.
Before editing the file need to find all the context.file by running below command.
Command: find . -name "context.xml"
Open those context.xml files and Disable the class by adding <!-- front of the class and --> end of the class and save the file.
Now stop and start the tomcat using the command “tomcatstop” and “tomcatstart”.
Now refreshing the browser URL it will ask you the username and password. So we need to set the roles, username and password.
To add the username, password and roles need to change the directory to /opt/apache-tomcat-8.5.82/conf inside the conf we are able to see the file name called tomcat-users.xml. Open that file and add the below username,password and roles for the users.
<role rolename="manager-gui"/>
<role rolename="manager-script"/>
<role rolename="manager-jmx"/>
<role rolename="manager-status"/>
<user username="admin" password="admin123" roles="manager-gui,manager-script,manager-jmx,manager-status"/>
<user username="tomcat" password="tomcat" roles="manager-script"/>
<user username="techiev" password="techiev123" roles="manager-gui"/>
Once added save the file and restart the tomcat and login the using username and password.
Now we can able to see the Tomcat server up and running.