Article: Tomcat5 on (Suse) Linux »
FERDY CHRISTANT - OCT 22, 2005 (10:58:28 AM)
|Suse 9.3 is a fairly complete Linux distribution that comes with Apache, PHP, but also Tomcat, if you enable it. I enabled it, but had many problems getting it to work. After a few frustrating hours I still had nothing but an empty Tomcat welcome page. I decided to start from scratch, minutes later I had everything working.|
I had a lot of problems with my existing Tomcat installation. I therefore wanted it to be completely removed from my system, so I could start from scratch:
- First stop the Tomcat service if it is running, by issueing the following command:
Alternatively, you can use the YaST system services panel to stop the Tomcat service.
- Next, remove all Tomcat packages from your system. Go to the YaST install and remove software panel, search for "tomcat" and uninstall the tomcat packages (there were 5 in my case).
- The previous step cleared out the packages, but left some files on the system that can conflict with your new installation. Therefore, be sure to remove the "/srv/www/tomcat5" directory completely.
Now that we have a clean installation, there are two ways to install Tomcat. You can install fresh Tomcat and JVM packages and set up the whole thing manually. Or, you can let your distribution take care of it. Since Suse 9.3 comes with Tomcat, I prefer to let YaST take care of the install:
- Open up the YaST install and remove software panel, search for "tomcat" and install all 5 resulting packages. It is important that you also select the "sample web applications" package, as this contains the Tomcat welcome page and example applications. This will make it easy to check if your installation is working correctly later on.
Check if the CATALINA system variables are set correct. These variables tell the system where to look for the Tomcat software. Normally, the previous step has taken care of these values, but it doesn't hurt to check them. Open the YaST /etc/SysConfigEditor and drill down to "Network/WWW/J2EE/Tomcat". The values there should be as follow:
variable value CATALINA_HOME /usr/share/tomcat5 CATALINA_BASE
Note: it's not a typo, CATALINA_BASE should really be left empty.
Nowadays, Tomcat comes with a Deployer application. This enables you to deploy and update applications on Tomcat without having to reboot the server. Before we can use it, we need to define a user that is allowed to use this service. Edit the file "/srv/www/tomcat5/base/conf/tomcat-users.xml to add an administrator user to it. Below is my file, after adding the administrator (in bold):
- Now it's time to enable the Tomcat service. If you like to run it as a service, thus letting it start automatically upon booting, go to the YaST system services console and enable the Tomcat service.
<?xml version='1.0' encoding='utf-8'?>
<user username="tomcatadmin" password="pass" roles="admin,manager"/>
<user username="tomcat" password="tomcat" roles="tomcat"/>
<user username="role1" password="tomcat" roles="role1"/>
<user username="both" password="tomcat" roles="tomcat,role1"/>
Now that we have installed Tomcat, it is time to test if it is working correctly:
Although not neccessary, for a good test you may want to reboot your machine to see if Tomcat automatically starts.
Tomcat by default runs on port 8080. If you intend to do the test from a remote machine, first open up this port in the firewall settings. For now, I'll assume the test will be done locally.
Open your browser and point it to http://localhost:8080. If all goes well, the Tomcat welcome page will appear. Congratulations, your installation is successfull!
- As a final test, see if you can login to the Tomcat manager application, which let's you manage your applications. Open http://localhost:8080/manager/html and login using the credentials of the admin user we added in the tomcat-users.xml file. If the Tomcat Web Application Manager page appears, you have successfully set up the complete installation.
If you are still having problems getting everything to work, check out following log files on your system:
If you installed the Tomcat sample application, which contains the Tomcat welcome page, you can find some excellent documentation in the following location: http://localhost:8080/tomcat-docs/
Tomcat really is a subproject of the Apache Jakarta project. The Jakarta project is a treasure of open source frameworks, components and libraries. Be sure to learn about the Jakarta Commons sub-project, it provides world-class libraries for your benefit.