This article provides information about the installation and basic configuration of Apache Tomcat on RHEL and its clones.
- Checking the Status of Tomcat
- Configuration Files
- Enabling HTML Management Access
- Deploying Applications
- Linux HTTP and FTP Server Configuration (RHCSA)
- Linux HTTP Server Configuration (RHCE)
- Apache : Reverse Proxy Configuration
- Apache Tomcat 7 Installation on Windows
- Apache Tomcat 7 Installation on Linux (RHEL and clones)
- Apache Tomcat 8 Installation on Linux (RHEL and clones)
Installing Tomcat on Linux is pretty simple if you’re using a YUM repository. You just need to make sure you’ve got Java installed already, then install the Tomcat packages. Tomcat7 is available from the Tomcat website, but the default version for OL6 is Tomcat6.
# yum install java # yum install tomcat6 tomcat6-webapps tomcat6-admin-webapps
The tomcat6-webapps and tomcat6-admin-webapps packages are not strictly speaking necessary, but they do give you access to a HTML management interface that makes things easier for a newbie.
Once installed, make sure the service is started and set to auto-start on reboot.
# chkconfig tomcat6 on # service tomcat6 start
The default page is visible on port 8080, so on the server itself you can access it using this URL “http://localhost:8080″.
Remember to open up the port on the firewall if you want to access the site from other servers on the network. Information about the Linux firewall is available here.
Checking the Status of Tomcat
There are several ways to check the status of the service.
# service tomcat6 status tomcat6 (pid 4470) is running... [ OK ] # # netstat -nlp | grep 8080 tcp 0 0 :::8080 :::* LISTEN 4470/java # # ps -ef | grep tomcat tomcat 15937 1 1 13:04 ? 00:00:08 /usr/lib/jvm/jre/bin/java -Djavax.sql.DataSource.Factory=org.apache.commons.dbcp.BasicDataSourceFactory -classpath :/usr/share/tomcat6/bin/bootstrap.jar:/usr/share/tomcat6/bin/tomcat -juli.jar:/usr/share/java/commons-daemon.jar -Dcatalina.base=/usr/share/tomcat6 -Dcatalina.home=/usr/share/tomcat6 -Djava.endorsed.dirs= -Djava.io.tmpdir=/var/cache/tomcat6/temp -Djava.util.logging.config.file=/usr/share/tomcat6/conf/logging.properties -Djava.util.logging.manager=org.apache.juli.ClassLoaderLogManager org.apache.catalina.startup.Bootstrap start root 16000 3167 0 13:16 pts/0 00:00:00 grep tomcat #
The status is also available from the HTML management page.
The main locations of configuration and log information are shown below.
Tomcat Service Config: /etc/tomcat6 (main config directory) Release Notes : /usr/share/doc/tomcat* Bin Directory : /usr/share/tomcat6 Webapps : /var/lib/tomcat6/webapps Logs : /var/log/tomcat6
Enabling HTML Management Access
Edit the “/usr/share/tomcat6/conf/tomcat-users.xml” file, adding a new role and user with admin privileges.
<role rolename="manager"/> <user name="tomcat" password="password" roles="manager" />
Restart Tomcat for the configuration to take effect.
# service tomcat6 restart
The management application is now available from the “http://localhost:8080/manager/html” URL.
You can get a sample application WAR file to test with from “http://tomcat.apache.org/tomcat-6.0-doc/appdev/sample/“.
If this is a redeployment, delete the existing deployment from the “/var/lib/tomcat6/webapps” directory.
# rm -Rf /var/lib/tomcat6/webapps/sample
Place the “sample.war” file in the “/var/lib/tomcat6/webapps” directory and Tomcat with automatically deploy it. You will see a “sample” directory appear.
You don’t need to stop and start Tomcat for this to work, but you can if you want.
# service tomcat6 stop # rm -Rf /var/lib/tomcat6/webapps/sample* # cp /path/to/sample.war /var/lib/tomcat6/webapps/sample.war # service tomcat6 start
For more information see: