This is a quick HowTo for Tomcat7 on Redhat Enterprise Linux and CentOS 7. The shortest answer to how to install Tomcat7 is to download it, extract it and start it. It runs natively on port 8080 so adjust your firewall accordingly or change the port that Tomcat wants to use.
As of this update, Tomcat 7 comes from Yum in RHEL 7 so you can skip the manual installation process. I’ve left it here just in-case you need a specific version. Also note that installing from Yum means you get the right service control with “systemctl”, etc.
Download Tomcat7 from:
wget http://www.us.apache.org/dist/tomcat/tomcat-7/v7.0.67/bin/apache-tomcat-7.0.67.tar.gz -O /tmp/tomcat7.tar.gz
The above location can change. In that case navigate to “http://www.us.apache.org/dist/tomcat/tomcat-7/” and then find the version you want.
tar -xzf /tmp/tomcat7.tar.gz -C /usr/local/ mv /usr/local/apache-tomcat-7.0.67 /usr/local/tomcat7
Set the password and permissions in the “/usr/local/tomcat7/conf/tomcat-users.xml” file. You can remove the contents of this file and replace is with the following. Change the password to something secret:
<tomcat-users> <role rolename="manager-gui" /> <user username="manager" password="MySecretPassword" roles="manager-gui" /> <role rolename="admin-gui" /> <user username="admin" password="MySecretPassword" roles="manager-gui,admin-gui" /> </tomcat-users>
Now you can start it by running:
And stop it with:
Finally you can test it by browsing to “http://my.example.com:8080/” and you will see the Tomcat7 welcome page. Use the menu buttons to access status and management functions. You’ll need the password to access these special locations.
Consider putting the start script in the “/etc/rc.local” file above any “exit” command to have Tomcat7 start on boot.