카테고리 없음

centos 에 tomcat7 설치

[czar] 2011. 7. 11. 15:04

http://www.tech-problems.com/install-tomcat-7-on-fedoracentos/

Find and copy download link from here: http://www.oracle.com/technetwork/java/javase/downloads/jdk-6u25-download-346242.html

2 mv jdk-6u25-linux-x64.bin* /opt/jdk-6u25-linux-x64.bin
3 mkdir /usr/java
4 cd /usr/java
5 sh /opt/jdk-6u25-linux-x64.bin

1 JAVA_HOME=/usr/java/jdk1.6.0_25
2 export JAVA_HOME
3 PATH=$JAVA_HOME/bin:$PATH
4 export PATH
5 vi /etc/profile.d/java.sh

Add to file

1 JAVA_HOME=/usr/java/jdk1.6.0_25
2 export JAVA_HOME
3 PATH=$JAVA_HOME/bin:$PATH
4 export PATH

Save and exit using :x

1 chmod +x /etc/profile.d/java.sh
2 echo $JAVA_HOME

Should display /usr/java/jdk1.6.0_25

Find the latest download link here for the Core Tar file http://tomcat.apache.org/download-70.cgi

1 cd /root
3 mv apache-tomcat-7.0.12.tar.gz /usr/share/apache-tomcat-7.0.12.tar.gz
4 cd /usr/share
5 tar -xzf apache-tomcat-7.0.12.tar.gz
6 cd /etc/init.d
7 vi tomcat

In this new file copy the following:

01 #!/bin/bash
02 # description: Tomcat Start Stop Restart
03 # processname: tomcat
04 # chkconfig: 234 20 80
05 JAVA_HOME=/usr/java/jdk1.6.0_25
06 export JAVA_HOME
07 PATH=$JAVA_HOME/bin:$PATH
08 export PATH
09 CATALINA_HOME=/usr/share/apache-tomcat-7.0.12
10  
11 case $1 in
12 start)
13 sh $CATALINA_HOME/bin/startup.sh
14 ;;
15 stop)
16 sh $CATALINA_HOME/bin/shutdown.sh
17 ;;
18 restart)
19 sh $CATALINA_HOME/bin/shutdown.sh
20 sh $CATALINA_HOME/bin/startup.sh
21 ;;
22 esac
23 exit 0

Save this and run the following command

1 chmod 755 tomcat
2 chkconfig --add tomcat
3 chkconfig --level 234 tomcat on

You can now start, stop and restart tomcat using:

1 service tomcat stop
2 service tomcat start
3 service tomcat restart

Allowing Port 80 through firewall and redirecting 8080 to port 80

1 /sbin/iptables -I INPUT 1 -p tcp --dport 8080 -j ACCEPT
2 /sbin/iptables -I INPUT 1 -p tcp --dport 80 -j ACCEPT
3 iptables -t nat -A PREROUTING -p tcp -m tcp --dport 80 -j REDIRECT --to-ports 8080
4 iptables -t nat -A PREROUTING -p udp -m udp --dport 80 -j REDIRECT --to-ports 8080
5 /sbin/service iptables save
6 service iptables restart

1 vi /usr/share/apache-tomcat-7.0.12/conf/tomcat-users.xml
2 <role rolename="manager-gui">
3 <user username="tomcat" password="s3cret" roles="manager-gui">
4 </user></role>