LinuxQuestions.org

LinuxQuestions.org (/questions/)
-   Linux - Newbie (https://www.linuxquestions.org/questions/linux-newbie-8/)
-   -   Help needed to install Apache Tomcat (https://www.linuxquestions.org/questions/linux-newbie-8/help-needed-to-install-apache-tomcat-805099/)

pinga123 04-30-2010 01:16 AM

Help needed to install Apache Tomcat
 
I want to setup apache tomcat on my linux distribution .

I Have downloaded apache tomcat from below mentioned link.

Administration Web Application:
http://tomcat.apache.org/download-55.cgi

The setup was in following format.
apache-tomcat-5.5.29-admin.tar.gz

Below are the command i have used to install the software.
I have copied the file to / directory
Quote:

gunzip apache-tomcat-5.5.29-admin.tar.gz
tar -xvf apache-tomcat-5.5.29-admin.tar
Now there is a folder called apache-tomcat-5.5.29 in my root directory.

I m currently stuck at this step .What should be my next step. i had no trouble installing it on my windows box but since i m new to linux request you to help me install it.

My linux distribution detail:
Quote:

LSB Version: :core-3.1-ia32:core-3.1-noarch:graphics-3.1-ia32:graphics-3.1-noarch
Distributor ID: EnterpriseEnterpriseServer
Description: Enterprise Linux Enterprise Linux Server release 5.2 (Carthage)
Release: 5.2
Codename: Carthage
Java Version:
Quote:

# java -version
java version "1.4.2"
gij (GNU libgcj) version 4.1.2 20071124 (Red Hat 4.1.2-42)

Copyright (C) 2006 Free Software Foundation, Inc.
This is free software; see the source for copying conditions. There is NO
warranty; not even for MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.

pinga123 04-30-2010 01:25 AM

After few searching here and there i came to know that i needed to install tomcat core setup first .

I have now installed core tomcat.

Now whenever i run startup.sh .It says
Quote:

"Neither the JAVA_HOME nor the JRE_HOME environment variable is defined
At least one of these environment variable is needed to run this program
"
What should be the next step?
How can i determine whether the java installed on my os or not.
Output of java -version
Quote:

java version "1.4.2"
gij (GNU libgcj) version 4.1.2 20071124 (Red Hat 4.1.2-42)

Copyright (C) 2006 Free Software Foundation, Inc.
This is free software; see the source for copying conditions. There is NO
warranty; not even for MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.

pinga123 04-30-2010 06:00 AM

I have somehow managed to run startup.sh


Quote:

[root@TESTOVM bin]# ./startup.sh
Using CATALINA_BASE: /apache-tomcat-5.5.29
Using CATALINA_HOME: /apache-tomcat-5.5.29
Using CATALINA_TMPDIR: /apache-tomcat-5.5.29/temp
Using JRE_HOME: /usr/java/jre1.6.0_20
Using CLASSPATH: /apache-tomcat-5.5.29/bin/bootstrap.jar
Now how do i access the home page of tomcat?

spidy402 05-17-2010 06:20 AM

I faced the same problem. Same as Pinga123....
But no one their to replay or direct any solution...
Where is moderation... ?
This site is still working. ?
Hey Pinga123 !!! Let me find solution on other site...and if it work for me i post here...
Linux is hard but not impossible.

ajeetsinghraina 05-17-2010 06:57 AM

Guys,
Hang on !!

Code:

Where is moderation... ?
You can't force anyone to answer you in so short time. this is an open collaborative project and not the paid service.
For experts from any particular field answer your query , you need to wait.

alli_yas 05-17-2010 07:13 AM

@post #4

Quote:

Where is moderation... ?
This site is still working. ?
My friend, we are not paid to help you with your university work or your job itself. We are a community who dedicate ourselves to helping people learn Linux and thus grow the community.

Thus no amount of moderation forces ANY member of this site to respond to your little outbursts. And yes this site is still working 100%...if you look at the way pinga_123 tried to figure stuff out himself; this is what is promoted on LQ - try to figure stuff out yourself with members helping you out along the way.

@pinga_123

The home page for Tomcat can be accessed at http://localhost:8080/ if you did the default install.

Just out of curiousity, is there a reason that you're using such an old version of Tomcat (the latest is Tomcat 6)?

Cheers
Yas

pinga123 05-17-2010 11:33 PM

Quote:

Originally Posted by alli_yas (Post 3971334)
@post #4



My friend, we are not paid to help you with your university work or your job itself. We are a community who dedicate ourselves to helping people learn Linux and thus grow the community.

Thus no amount of moderation forces ANY member of this site to respond to your little outbursts. And yes this site is still working 100%...if you look at the way pinga_123 tried to figure stuff out himself; this is what is promoted on LQ - try to figure stuff out yourself with members helping you out along the way.

@pinga_123

The home page for Tomcat can be accessed at http://localhost:8080/ if you did the default install.

Just out of curiousity, is there a reason that you're using such an old version of Tomcat (the latest is Tomcat 6)?

Cheers
Yas

Thanks for your help .
I m going to Post my experience in installing TOMCAT on linux.

Your comments are highly appreciated.

OS : Oracle Enterprise Linux 5.2 32bit
Step1: Install Tomcat, JDK, JRE

We are going to install following softwares in the newly created machines.

Make a folder named install in /.
Copy all the required softwares in /install.

Quote:

apache-tomcat-5.5.29.tar.gz
jdk-6u20-linux-i586-rpm.bin
jre-6u20-linux-i586-rpm.bin
Installation Guide:

1)apache-tomcat-5.5.29.tar.gz:

I have choosen linux version of tomcat.
For Initial Setup You should always go for
Core version download.
downloaded apache-tomcat-5.5.29.tar.gz
Code:

#gunzip apache-tomcat-5.5.29.tar.gz
#tar -xvf apache-tomcat-5.5.29.tar.gz

This will create a new folder as apache-tomcat-5.5.29 in same directory.
go to apache-tomcat-5.5.29/bin
run
Code:

#./startup.sh
it will not run as java new version is not yet installed.

2) jdk-6u20-linux-i586-rpm.bin:
Next we will install latest jdk version.
Code:

chmod +x jdk-6u20-linux-i586-rpm.bin
#./ jdk-6u20-linux-i586-rpm.bin

This will create a new folder in
Code:

/usr/java/jdk1.6.0_20/
use it for JAVA_HOME.



3) jre-6u20-linux-i586-rpm.bin
Next we will install latest jre version.
Code:

chmod +x jre-6u20-linux-i586-rpm.bin
#./jre-6u20-linux-i586-rpm.bin

This will create a new folder in
/usr/java/jre1.6.0_20/
use it for JRE_HOME.

Step2:Configure java and TOMCAT

# javac -version
javac 1.6.0_20
# java -version
java version "1.4.2"
gij (GNU libgcj) version 4.1.2 20071124 (Red Hat 4.1.2-42)

Copyright (C) 2006 Free Software Foundation, Inc.
This is free software; see the source for copying conditions. There is NO
warranty; not even for MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.


######At this time java is set to default java in linux our aim is to change it to latest java version.
for setting up this you need root login therefore type

Code:

#su
######Then you type

Code:

#/usr/sbin/alternatives --install /usr/bin/java java /usr/java/jdk1.6.0_20/bin/java 2
######Finally you type
Code:

#;/usr/sbin/alternatives --config java
........ and choose '2'nd option.


Now make sure you disable firewall .
Code:

# system-config-securitylevel
Disable the firewall

I have created a script called Tomcat and pasted following content inside it.(All credit goes to original script writer)
Code:

#        This is the init script for starting up the
#                Jakarta Tomcat server
#
# chkconfig: 345 91 10
# description: Starts and stops the Tomcat daemon.
#

# Source function library.
. /etc/rc.d/init.d/functions

# Get config.
. /etc/sysconfig/network

# Check that networking is up.
[ "${NETWORKING}" = "no" ] && exit 0

tomcat=/install/apache-tomcat-5.5.29
startup=$tomcat/bin/startup.sh
shutdown=$tomcat/bin/shutdown.sh
export JAVA_HOME=/usr/java/jdk1.6.0_20


start(){
        echo -n $"Starting Tomcat service: "
        #daemon -c
        $startup
        RETVAL=$?
        echo
}

stop(){
        action $"Stopping Tomcat service: " $shutdown       
        RETVAL=$?
        echo
}

restart(){
    stop
    start
}


# See how we were called.
case "$1" in
  start)
        start
        ;;
  stop)
        stop
        ;;
  status)
        # This doesn't work ;)
        status tomcat
        ;;
  restart)
        restart
        ;;
  *)
        echo $"Usage: $0 {start|stop|status|restart}"
        exit 1
esac

exit 0


Edit the lines that start with tomcat and export to match

Save the script with name “tomcat” to a location “/etc/init.d”

(at least on most newer releases since /etc/init.d is a standard now). Then you have to allow execute access to the script, so run:

Code:

chmod a+x tomcat
Add to appropriate run level directories

The easy way to do this is to just simply run:

Code:

chkconfig --add tomcat

Add username/Password for tomcat manager:
How to add a new user name to tomcat manager:

just add line number 3 and 6 to /install/apache-tomcat-5.5.29/conf/tomcat-users.xml
Quote:

1) <?xml version='1.0' encoding='utf-8'?>
2) <tomcat-users>
3) <role rolename="manager"/>
4) <role rolename="tomcat"/>
5) <role rolename="role1"/>
6) <user username="manager" password="tomcat" roles="manager,tomcat"/>
7) <user username="tomcat" password="tomcat" roles="tomcat"/>
8) <user username="both" password="tomcat" roles="tomcat,role1"/>
9) <user username="role1" password="tomcat" roles="role1"/>
10) </tomcat-users>
Restart tomcat server.
By using service tomcat restart.

If anybody faces any issue just PM me .I will try to help as soon as possible.

Some additional Information::

To check whether the Tomcat is running or not.(Contributed by Alli yas).

Code:

#netstat -ntpl | grep java
tcp        0      0 ::ffff:127.0.0.1:8005      :::*                        LISTEN      6375/java
tcp        0      0 :::8009                    :::*                        LISTEN      6375/java
tcp        0      0 :::8080                    :::*                        LISTEN      6375/java

You should see at least one java process and you can use ps to identify if this is Tomcat.
Code:

# ps -ef | grep 6375
root      6375    1  0 May18 pts/2    00:01:06 /usr/java/jdk1.6.0_20/bin/java -Djava.util.logging.config.file=/install/apache-tomcat-5.5.29/conf/logging.properties -Djava.util.logging.manager=org.apache.juli.ClassLoaderLogManager -Djava.endorsed.dirs=/install/apache-tomcat-5.5.29/common/endorsed -classpath /install/apache-tomcat-5.5.29/bin/bootstrap.jar -Dcatalina.base=/install/apache-tomcat-5.5.29 -Dcatalina.home=/install/apache-tomcat-5.5.29 -Djava.io.tmpdir=/install/apache-tomcat-5.5.29/temp org.apache.catalina.startup.Bootstrap start
root      9222  5091  0 18:29 pts/2    00:00:00 grep 6375


ajeetsinghraina 05-18-2010 12:21 AM

You can rather put it under one of your blog and refer the post whenever anyone faces issue setting up Apache and Tomcat.
Good work !!

alli_yas 05-18-2010 02:54 AM

Excellent stuff pinga_123 :D

To add on to what you've done. If ever you want to debug whether Tomcat has started do the following:

Code:

#netstat -ntpl
You should see at least one java process and you can use ps to identify if this is Tomcat.

Also, monitor $CATALINA_HOME/logs/catalina.out - this is a VERY useful file that will show any exceptions that are thrown if the app server fails to start.

Feel free to PM me as well for Tomcat related issues:)

captain_sensible 05-18-2010 03:12 AM

hi

just wanted to add that also had problems with Tomcat & as a newbie didn't want to do to much configuation.
The bigest problem was path, java_home etc; i think i'm right in saying that if you use apt-get your system configures these setting s for you

At the end of this post is a link to how I did it. Also if your goingto get Tomcat I don't see the point in needig Apache since Tomcat serves html files just as easily as jsp files.

http://www.linuxquestions.org/questi...needed-802179/

alli_yas 05-18-2010 03:48 AM

Quote:

just wanted to add that also had problems with Tomcat & as a newbie didn't want to do to much configuation.
The bigest problem was path, java_home etc; i think i'm right in saying that if you use apt-get your system configures these setting s for you
Yes you are right - when you install via a deb package (Ubuntu/Debian/etc) or rpm (Redhat/Fedora/CentOS) - the person who built the package has already defined the way in which the package will be extracted and installed.

Thus you need to either read the documentation for the rpm you have downloaded or query the rpm itself to try to determine where the different files will be placed.

Another way of doing things (I'm not saying its right - its what I do to make my life easier :D) is to download and install applications manually via either tarballs (Tomcat), binary installs (java), source etcetera - its longer and a bit more difficult; but you can control where things are installed - and you won't have trouble with JAVA_HOME locations and so forth.

Quote:

Also if your goingto get Tomcat I don't see the point in needig Apache since Tomcat serves html files just as easily as jsp files
There definitely is a point to Apache (or any other dedicated web server). Sure Tomcat can serve up html; but it is not an advanced web server like Apache is - things like reverse proxies, virtual hosting, load balancing modules etcetera are not supported on Tomcat.

Further, remember that Tomcat is tightly coupled to the JVM, so if your Java fails for some reason; then your web server also fails - versus Apache which will continue running - this thus is also a consideration.

pinga123 05-19-2010 02:31 AM

Quote:

Originally Posted by alli_yas (Post 3972449)
Excellent stuff pinga_123 :D

To add on to what you've done. If ever you want to debug whether Tomcat has started do the following:

Code:

#netstat -ntpl
You should see at least one java process and you can use ps to identify if this is Tomcat.

Also, monitor $CATALINA_HOME/logs/catalina.out - this is a VERY useful file that will show any exceptions that are thrown if the app server fails to start.

Feel free to PM me as well for Tomcat related issues:)

Thank you very much.
I tried as you said its work great . I m posting the result of my output.

Code:

#netstat -ntpl | grep java
tcp        0      0 ::ffff:127.0.0.1:8005      :::*                        LISTEN      6375/java
tcp        0      0 :::8009                    :::*                        LISTEN      6375/java
tcp        0      0 :::8080                    :::*                        LISTEN      6375/java
# ps -ef | grep 6375
root      6375    1  0 May18 pts/2    00:01:06 /usr/java/jdk1.6.0_20/bin/java -Djava.util.logging.config.file=/install/apache-tomcat-5.5.29/conf/logging.properties -Djava.util.logging.manager=org.apache.juli.ClassLoaderLogManager -Djava.endorsed.dirs=/install/apache-tomcat-5.5.29/common/endorsed -classpath /install/apache-tomcat-5.5.29/bin/bootstrap.jar -Dcatalina.base=/install/apache-tomcat-5.5.29 -Dcatalina.home=/install/apache-tomcat-5.5.29 -Djava.io.tmpdir=/install/apache-tomcat-5.5.29/temp org.apache.catalina.startup.Bootstrap start
root      9222  5091  0 18:29 pts/2    00:00:00 grep 6375


captain_sensible 05-19-2010 02:02 PM

alli yas

thanks for info

so your are talking about ... tar xfv tarball

./configure
make
make install

i have done that a couple of times with other more simple programmes but not tomcat.
ok so you download tomcat source from jakarta or equivalnet source. i'm interested in an outline of the install sequence
my path to ROOT (tomcat web root) is /var/lib/tomcat6/webapps/ROOT although once it ended up user/share/
so would you mkdir tomcat6 in /var/lib/ then untar inside tomcat6 or would that end up tomcat6/tomcat6
something along those lines....

brucehinrichs 05-19-2010 02:14 PM

Quote:

so your are talking about ... tar xfv tarball

./configure
make
make install
This is generally how to compile packages in linux. Some packages do it a little differently for different reasons. The best bet is to read any documentation (README, INSTALL, something similar) for specific instructions.

spuds99 11-08-2010 05:43 PM

Tomcat script throwing errors
 
All,

I am trying to set up Tomcat v6 to run on a red hat server. I copied the "tomcat" script above in this thread, edited it, and am trying to run from the command as a first step.

I get the following feedback:

serverY#./tomcat start
: command not found
: No such file or directory.d/functions
: command not found
: command not found
: command not found
'/tomcat: line 23: syntax error near unexpected tokem '{
'/tomcat: line 22: 'start(){

Here are my changes to the tomcat script:

# source function library
. /etc/init.d/functions

# get config
. /etc/sysconfig/network-scripts

...

tomcat=/usr/ .../apache-tomcat-6...
...
export JAVA_HOME=/usr/java/jdk1.6.0_21

Can you give me some ideas on how to debug this script?

Thank you.

- Spuds

alli_yas 11-08-2010 11:13 PM

Hi spuds99

Welcome to LQ :)

Please take some time to read the rules an "How to ask questions the Smart way" - you'll find the links in my signature below.

Note that "thread-jacking" is against the rules; thus even if a thread is similar to yours, please create a new thread with your questions/problem.

@Mods - please move this to a new thread.

Regarding your issue; simply copying the script is not going to get Tomcat working. Please provide details of how and where you've installed Tomcat. Also post the complete script and make use of Code tags to make it more readable.

pinga123 11-09-2010 01:21 AM

Make sure you have /usr/java/jdk1.6.0_20 directory and tomcat variable properly set (In my case it is /install/apache-tomcat-5.5.29
but it may differ in your case) .

Make these changes in your script and then try to run it.
It may not run if you copy paste it you may need to change these 2 parameter manually.


All times are GMT -5. The time now is 06:17 AM.