How to Install and Configure Apache-Tomcat 6 on Debian 5 LENNY with apache2
This article is a „how to“ to install the tomcat with apache 2. I will try to explain each and every step so that if anything goes wrong one can revert it or can easily figure out the problem and correct it.
Installing Java 6 runtime:
Please try to install sun JDK because there is a big difference between configurations of sun JDK and open JDK. Installation of sun JDK is given as under;
Sun JDK (non-free)
deb http://ftp.de.debian.org/debian/ lenny main non-free
deb-src http://ftp.de.debian.org/debian/ lenny main non-free
Please copy and paste the above lines and add in /etc/apt/sources.list
vi /etc/apt/sources.list
Please update the aptitude by using the under given command.
aptitude update
aptitude install sun-java6-jdk
Go to /etc/profile and enter the path of the JDK if its not updated automatically.
Enter the path like under given;
export PATH
JAVA_HOME=”/usr/lib/jvm/java-6-sun/”
export JAVA_HOME
Download Tomcat
Now download tomcat 6 from the tomcat 6 download page.
For example:
Use wget to download the apache-tomcat to /tmp directory.
wget http://apache.imsam.info/tomcat/tomcat-6/v6.0.18/bin/apache-tomcat-6.0.18.tar.gz
Installing Tomcat
tar -xzvf apache-tomcat-6.0.18.tar.gz
mv apache-tomcat-6.0.18 /opt/tomcat
Init script
vi /etc/init.d/tomcat
Change the permissions of the above created file to 0755 so that it can be executed at startup and also by giving the start/stop/restart command. Just copy and paste the under given text to the above given file.
#!/bin/sh
# Tomcat Init-Script
case $1 in
start)
sh /opt/tomcat/bin/startup.sh
;;
stop)
sh /opt/tomcat/bin/shutdown.sh
;;
restart)
sh /opt/tomcat/bin/shutdown.sh
sh /opt/tomcat/bin/startup.sh
;;
esac
exit 0
update-rc.d tomcat defaults
Enabling the Tomcat Manager
vi /opt/tomcat/conf/tomcat-users.xml
< ?xml version=’1.0′ encoding=’utf-8′?>
<tomcat-users>
<role rolename=”manager”/>
<role rolename=”admin”/>
<user username=”USERNAME” password=”PASSWORD” roles=”admin,manager”/>
</tomcat-users>
Start Tomcat
/etc/init.d/tomcat start
Now you can open Tomcat Manager with under given web address. Please replace the SERVERNAME with your server name or IP address.
http://SERVERNAME:8080/manager/html
Till here the tomcat server is installed and configured properly. There is a built in apache web server in the tomcat.
Installing the Apache2 Connectors
Tomcat has a built-in Web server, but the Apache2 web server is much more powerful as the Apache modules used. i.e. mod_rewrite
aptitude install apache2 libapache2-mod-jk
Now Create a file named workers.properties at under given address.
vi /etc/apache2/workers.properties
workers.tomcat_home=/opt/tomcat
workers.java_home=/usr/lib/jvm/java-6-sun
ps=/
worker.list=default
worker.default.port=8009
worker.default.host=localhost
worker.default.type=ajp13
worker.default.lbfactor=1
JK configuration file
vi /etc/apache2/conf.d/jk.conf
<ifmodule mod_jk.c>
JkWorkersFile /etc/apache2/workers.properties
JkLogFile /var/log/apache2/mod_jk.log
JkLogLevel error
</ifmodule>
/etc/init.d/apache2 stop
/etc/init.d/tomcat restart
/etc/init.d/apache2 start
Creating a New Virtual Host
Now let’s create a new Virtual Host. This must be created in apache2 and Tomcat.
Creating Directories
mkdir /var/www/vhost1
mkdir /var/www/vhost1/htdocs
mkdir /var/www/vhost1/logs
vi /etc/apache2/sites-available/vhost1
Apache
<virtualhost www.testsrv.local>
JkMount /*.jsp default
ServerName www.testsrv.local
ServerAdmin servermaster@testsrv.local
DocumentRoot /var/www/vhost1/htdocs
ErrorLog /var/www/vhost1/logs/error.log
CustomLog /var/www/vhost1/logs/access.log common
<directory /var/www/vhost1/htdocs>
Options -Indexes
</directory>
</virtualhost>
Note: You could also select all the files to the Tomcat forwared “JkMount / *” or all files within a directory “JkMount / folder / *”.
a2ensite vhost1
/etc/init.d/apache2 reload
Tomcat
vi /opt/tomcat/conf/server.xml
<!– www.testsrv.local –>
<host name=”www.testsrv.local” appBase=”/var/www/vhost1″
unpackWARs=”true” autoDeploy=”true”>
<context path=”" docBase=”htdocs” debug=”0″ reloadable=”true”/>
<valve className=”org.apache.catalina.valves.AccessLogValve”
directory=”/var/www/vhost1/logs” prefix=”tomcat_access_” suffix=”.log”
pattern=”common” resolveHosts=”false”/>
</host>
/etc/init.d/tomcat restart
<alias>additionaldomain.com</alias>
Now Let’s create a Test page.
vi /var/www/vhost1/htdocs/test.jsp
<html>
<head>
<title>Hello World</title>
</head>
<body>
<h1>Hello World</h1>
Today is: < %= new java.util.Date().toString() %>
</body>
</html>
See Also how to configure multiple Instances of Apache-Tomcat 6 on Debian 5 Lenny;
http://www.itoperationz.com/2009/07/multiple-instances-of-apache-tomcat-6-on-debain5-lenny/
If you are looking for the information about the installation and configuration of apache tomcat 6 on debian lenny please visit the URL given as under;
http://www.itoperationz.com/2010/04/how-to-install-apache-tomcat-6-on-debian-5-lenny/
Popularity: 100% [?]
5 Comments to “How to Install and Configure Apache-Tomcat 6 on Debian 5 LENNY with apache2”
Post comment
Recent Posts
- Windows VS Windows
- Download The Best Skins Of Windows Media Player
- Lucky Microsoft, Getting Malware Code Automatically
- Use Linux and Unix Operating Systems On Your Web Browser
- Microsoft Security Essentials Error 0×80070643
Categories
- Cisco
- Dell Servers
- Development
- Gadgets
- IPHONE
- IT
- IT Operations
- ITIL
- LINUX
- Microsoft
- Microsoft Exchange Server
- Microsoft Office
- Microsoft Utilities
- Open Source
- PowerEdge 2650
- Router 2811
- Service Desk
- Software
- Tech News
- UNIX
- Utilities
- Video
- VMware
- WEB
- Web Server
- windows
- Windows 7
[...] http://www.itoperationz.com/2009/06/how-to-install-and-configure-apache-tomcat-6-on-debian-5/ [...]
I can’t find any faults with this, except maybe that you use vi instead of emacs
It was nice to find something that helped finally, after a whole day of googling and monkeying around.
[WORDPRESS HASHCASH] The poster sent us ’0 which is not a hashcash value.
This is a superb article, i’m happy I stumbled onto it. Ill be back again down the track to check out other posts that you have on your blog.
The following how-to worked for me. http://www.debianadmin.com/how-to-setup-apache-tomcat-55-on-debian-etch.html
More specifically, to verify that Tomcat is running just navigate to http://localhost:8180/ and _NOT_ http://localhost:8080/ in your browser (make sure you have replaced ‘localhost’ with your server ip or name)
Hi
I’ve done “most” of the tutorial without problems but i fail in the last part, when it comes to create a test page, i get a 404 error, and the tomcat server is up and running i’ve followed everything but i fail there. Hope some1 can help me, thanks.