In this
post, I am going to explain how to setup Apache tomcat, and configure users to
work with tomcat web user interface.
Prerequisite
Make sure Java
is installed in your system.
Step 1:
Go to below location
and download Apache tomcat latest release.
https://tomcat.apache.org/
At the
time of writing this post 10.0.23 is the latest version.
Step 2:
Create tomcat folder
and extract the downloaded zip file contents to tomcat folder.
Step 3:
We need to give
execute permission to the scripts available in bin folder. Open terminal, navigate
to the bin folder and execute below command to give execute permissions to all
the .sh files.
chmod +x *sh
You can
confirm the same by executing ‘ls -lart’ command.
$ ls -lart *sh
-rw-r--r--@ 1 krishna staff 1908 Jul 14 10:16 version.sh
-rw-r--r--@ 1 krishna staff 5540 Jul 14 10:16 tool-wrapper.sh
-rw-r--r--@ 1 krishna staff 1904 Jul 14 10:16 startup.sh
-rw-r--r--@ 1 krishna staff 1902 Jul 14 10:16 shutdown.sh
-rw-r--r--@ 1 krishna staff 3708 Jul 14 10:16 setclasspath.sh
-rw-r--r--@ 1 krishna staff 1970 Jul 14 10:16 migrate.sh
-rw-r--r--@ 1 krishna staff 3382 Jul 14 10:16 makebase.sh
-rw-r--r--@ 1 krishna staff 1965 Jul 14 10:16 digest.sh
-rw-r--r--@ 1 krishna staff 8836 Jul 14 10:16 daemon.sh
-rw-r--r--@ 1 krishna staff 1922 Jul 14 10:16 configtest.sh
-rw-r--r--@ 1 krishna staff 1997 Jul 14 10:16 ciphers.sh
-rw-r--r--@ 1 krishna staff 24814 Jul 14 10:16 catalina.sh
$
$
$ chmod +x *sh
$
$ ls -lart *sh
-rwxr-xr-x@ 1 krishna staff 1908 Jul 14 10:16 version.sh
-rwxr-xr-x@ 1 krishna staff 5540 Jul 14 10:16 tool-wrapper.sh
-rwxr-xr-x@ 1 krishna staff 1904 Jul 14 10:16 startup.sh
-rwxr-xr-x@ 1 krishna staff 1902 Jul 14 10:16 shutdown.sh
-rwxr-xr-x@ 1 krishna staff 3708 Jul 14 10:16 setclasspath.sh
-rwxr-xr-x@ 1 krishna staff 1970 Jul 14 10:16 migrate.sh
-rwxr-xr-x@ 1 krishna staff 3382 Jul 14 10:16 makebase.sh
-rwxr-xr-x@ 1 krishna staff 1965 Jul 14 10:16 digest.sh
-rwxr-xr-x@ 1 krishna staff 8836 Jul 14 10:16 daemon.sh
-rwxr-xr-x@ 1 krishna staff 1922 Jul 14 10:16 configtest.sh
-rwxr-xr-x@ 1 krishna staff 1997 Jul 14 10:16 ciphers.sh
-rwxr-xr-x@ 1 krishna staff 24814 Jul 14 10:16 catalina.sh
From the above snippet, you can notice that prior to the execution of chmod command, *.sh files do not have execute permission, after that x flag is added to all the *sh files.
Step 4:
Execute the file
./startup.sh
bash-3.2$ ./startup.sh
Using CATALINA_BASE: /Users/krishna/Documents/softwares/tomcat
Using CATALINA_HOME: /Users/krishna/Documents/softwares/tomcat
Using CATALINA_TMPDIR: /Users/krishna/Documents/softwares/tomcat/temp
Using JRE_HOME: /Library/Java/JavaVirtualMachines/jdk-15.0.2.jdk/Contents/Home
Using CLASSPATH: /Users/krishna/Documents/softwares/tomcat/bin/bootstrap.jar:/Users/krishna/Documents/softwares/tomcat/bin/tomcat-juli.jar
Using CATALINA_OPTS:
Tomcat started.
Let’s
confirm the same by opening the url ‘http://localhost:8080/’ in browser.
That’s it
you are done with the setup…
How to
stop the tomcat server?
Execute
the command ‘./shutdown.sh’.
$./shutdown.sh
Using CATALINA_BASE: /Users/krishna/Documents/softwares/tomcat
Using CATALINA_HOME: /Users/krishna/Documents/softwares/tomcat
Using CATALINA_TMPDIR: /Users/krishna/Documents/softwares/tomcat/temp
Using JRE_HOME: /Library/Java/JavaVirtualMachines/jdk-15.0.2.jdk/Contents/Home
Using CLASSPATH: /Users/krishna/Documents/softwares/tomcat/bin/bootstrap.jar:/Users/krishna/Documents/softwares/tomcat/bin/tomcat-juli.jar
Using CATALINA_OPTS:
NOTE: Picked up JDK_JAVA_OPTIONS: --add-opens=java.base/java.lang=ALL-UNNAMED --add-opens=java.base/java.io=ALL-UNNAMED --add-opens=java.base/java.util=ALL-UNNAMED --add-opens=java.base/java.util.concurrent=ALL-UNNAMED --add-opens=java.rmi/sun.rmi.transport=ALL-UNNAMED
Another
way to start and stop the tomcat
./catalina.sh
start: Start the tomcat server.
$./catalina.sh start
Using CATALINA_BASE: /Users/krishna/Documents/softwares/tomcat
Using CATALINA_HOME: /Users/krishna/Documents/softwares/tomcat
Using CATALINA_TMPDIR: /Users/krishna/Documents/softwares/tomcat/temp
Using JRE_HOME: /Library/Java/JavaVirtualMachines/jdk-15.0.2.jdk/Contents/Home
Using CLASSPATH: /Users/krishna/Documents/softwares/tomcat/bin/bootstrap.jar:/Users/krishna/Documents/softwares/tomcat/bin/tomcat-juli.jar
Using CATALINA_OPTS:
Tomcat started.
./catalina.sh
stop: Stop the tomcat server.
$./catalina.sh stop
Using CATALINA_BASE: /Users/krishna/Documents/softwares/tomcat
Using CATALINA_HOME: /Users/krishna/Documents/softwares/tomcat
Using CATALINA_TMPDIR: /Users/krishna/Documents/softwares/tomcat/temp
Using JRE_HOME: /Library/Java/JavaVirtualMachines/jdk-15.0.2.jdk/Contents/Home
Using CLASSPATH: /Users/krishna/Documents/softwares/tomcat/bin/bootstrap.jar:/Users/krishna/Documents/softwares/tomcat/bin/tomcat-juli.jar
Using CATALINA_OPTS:
NOTE: Picked up JDK_JAVA_OPTIONS: --add-opens=java.base/java.lang=ALL-UNNAMED --add-opens=java.base/java.io=ALL-UNNAMED --add-opens=java.base/java.util=ALL-UNNAMED --add-opens=java.base/java.util.concurrent=ALL-UNNAMED --add-opens=java.rmi/sun.rmi.transport=ALL-UNNAMED
$
Configure
tomcat users
By default
there is no user configured with tomcat setup.
How to
add a tomcat user?
Open the
file ‘{TOMCAT_INSTALL_DIR}/conf/tomcat-users.xml’
Add below
statements between <tomcat-users> </tomcat-users> element.
<role rolename="manager-gui"/>
<user username="admin" password="admin" roles="manager-gui"/>
Start the tomcat server
again, open the url ‘http://localhost:8080’ in browser. Click on ‘Manager App’
button, it prompts you for the login details.
Enter
username as admin and password as admin, click on Sign In button. You will be
taken to ‘Tomcat Web Application Manager’ page.
Previous
Next
Home