Monday, July 8, 2013

Apache - Tomcat installation in Linux

[root@machine1 ~]# echo $JAVA_HOME
/usr/local/jdk1.7.0_17

[root@machine1 ~]# wget http://apache.spinellicreations.com/tomcat/tomcat-7/v7.0.41/src/apache-tomcat-7.0.41-src.tar.gz
--2013-07-06 22:43:04--  http://apache.spinellicreations.com/tomcat/tomcat-7/v7.0.41/src/apache-tomcat-7.0.41-src.tar.gz
Resolving apache.spinellicreations.com... 72.88.94.11
Connecting to apache.spinellicreations.com|72.88.94.11|:80... connected.
HTTP request sent, awaiting response... 200 OK
Length: 4407748 (4.2M) [application/x-gzip]
Saving to: “apache-tomcat-7.0.41-src.tar.gz”

100%[====================================================================>] 4,407,748    698K/s   in 12s

2013-07-06 22:43:24 (356 KB/s) - “apache-tomcat-7.0.41-src.tar.gz” saved [4407748/4407748]

[root@machine1 ~]# tar -zxvf apache-tomcat-7.0.41-src.tar.gz

[root@machine1 ~]# mv apache-tomcat-7.0.41-src /usr/local/

[root@machine1 ~]# cd /usr/local/

create symbolic link in the name tomcat

[root@machine1 local]# ln -s /usr/local/apache-tomcat-7.0.41-src ./tomcat

Run the following command and add it in .bash_profile.

[root@machine1 local]# export CATALINA_HOME=/usr/local/tomcat

[root@machine1 local]# cd

[root@machine1 ~]# vi .bash_profile
# User specific environment and startup programs

export JAVA_HOME=/usr/local/jdk1.7.0_17

PATH=/usr/local/jdk1.7.0_17/bin:$PATH:$HOME/bin

export JAVA_HOME
export CATALINA_HOME=/usr/local/tomcat
export PATH

save and exit

esnure that you also exported java path.

[root@machine1 ~]# $CATALINA_HOME/bin/startup.sh
-bash: /usr/local/tomcat/bin/startup.sh: Permission denied
cd /usr/local/tomcat/bin
chmod 700 *.sh


[root@machine1 bin]# /usr/local/tomcat/bin/startup.sh
Using CATALINA_BASE:   /usr/local/tomcat
Using CATALINA_HOME:   /usr/local/tomcat
Using CATALINA_TMPDIR: /usr/local/tomcat/temp
Using JRE_HOME:        /usr/local/jdk1.7.0_17
Using CLASSPATH:       /usr/local/tomcat/bin/bootstrap.jar:/usr/local/tomcat/bin/tomcat-juli.jar
touch: cannot touch `/usr/local/tomcat/logs/catalina.out': No such file or directory
/usr/local/tomcat/bin/catalina.sh: line 387: /usr/local/tomcat/logs/catalina.out: No such file or directory

[root@machine1 bin]# mkdir /usr/local/tomcat/logs

The problem is that the archive manager didn't create the empty logs folder, even though it was listed in the tar file. I guess it doesn't think empty directories are important. Anyway, just create a logs folder inside the tomcat folder:

    mkdir /usr/local/tomcat/logs

Tomcat should startup now. Another option would be to simply use the command line tools to extract the archive.
[root@machine1 bin]# export CATALINA_BASE=/usr/local/tomcat/

[root@machine1 bin]# /usr/local/tomcat/bin/startup.sh
Using CATALINA_BASE:   /usr/local/tomcat/
Using CATALINA_HOME:   /usr/local/tomcat
Using CATALINA_TMPDIR: /usr/local/tomcat//temp
Using JRE_HOME:        /usr/local/jdk1.7.0_17
Using CLASSPATH:       /usr/local/tomcat/bin/bootstrap.jar:/usr/local/tomcat/bin/tomcat-juli.jar


Using CLASSPATH:       /usr/local/apache-tomcat-6.0.36/bin/bootstrap.jar

[root@machine1 bin]# /etc/init.d/tomcat start
Starting Tomcat
Using CATALINA_BASE:   /usr/local/tomcat/
Using CATALINA_HOME:   /usr/local/tomcat/
Using CATALINA_TMPDIR: /usr/local/tomcat//temp
Using JRE_HOME:        /usr/local/jdk1.7.0_17
Using CLASSPATH:       /usr/local/tomcat//bin/bootstrap.jar

[root@machine1 bin]# /etc/init.d/tomcat stop
Stopping Tomcat
Using CATALINA_BASE:   /usr/local/tomcat/
Using CATALINA_HOME:   /usr/local/tomcat/
Using CATALINA_TMPDIR: /usr/local/tomcat//temp
Using JRE_HOME:        /usr/local/jdk1.7.0_17
Using CLASSPATH:       /usr/local/tomcat//bin/bootstrap.jar

[root@machine1 bin]# cat /etc/sysconfig/tomcat
JAVA_HOME="/usr/local/jdk1.7.0_17"
CATALINA_HOME="/usr/local/tomcat"
CATALINA_BASE="/usr/local/tomcat"
You have new mail in /var/spool/mail/root

add the script in /etc/init.d/tomcat

chmod 755 /etc/init.d/tomcat
chkconfig --add tomcat
chkconfig --list tomcat

Type localhost:8080 or your ip address:8080 in your browser to view



No comments: