Link.
1. Download Tomcat
cd /usr/local/srcwget http://labs.renren.com/apache-mirror/tomcat/tomcat-7/v7.0.39/bin/apache-tomcat-7.0.39.zip
Ii. Unzip and install Tomcat
unzip -d /usr/local apache-tomcat-7.0.39.zip
cd /usr/local
mv apache-tomcat-7.0.39/ tomcat1
3. Configure Environment Variables
vi /etc/profile
(1) Add at the end of the file
export JAVA_HOME=/usr/java/jdk1.7.0_17export JRE_HOME=/usr/java/jdk1.7.0_17/jreexport CLASSPATH=.:$JAVA_HOME/lib/dt.jar:$JAVA_HOME/lib/tools.jarexport PATH=$PATH:/sbin:/bin:/usr/sbin:/usr/bin:/usr/X11R6/bin:$JAVA_HOME/bin
(2)
CD/usr/local/tomcat1/bin
VI Catalina. Sh
#! /Bin/sh
Export tomcat_home =/usr/local/tomcat1
Export catalina_home =/usr/local/tomcat1
(3) Use the following command to grant the File Execution permission and make the configuration take effect.
# source /etc/profile
# cd /usr/local/tomcat1/bin
# chmod 777 *.*
4. Configure Tomcat
(1) Add tomcat to start automatically
Echo "Source/etc/profile">/etc/rc. d/rc. Local
Echo "/usr/local/tomcat1/bin/startup. Sh">/etc/rc. d/rc. Local
It should be noted that RC. Local is executed before/etc/profile, so the Java environment variable is not obtained, so you can add the code: Source/etc/profile before startup. Sh.
(2) Let the firewall open the Tomcat port. The last sentence is to save the rule.
# iptables -F# iptables -t nat -I PREROUTING -p tcp --dport 80 -j REDIRECT --to-ports 8080# iptables -t nat -I OUTPUT -p tcp --dport 80 -j REDIRECT --to-ports 8080# /etc/rc.d/init.d/iptables save
V. Test
# cd /usr/local/tomcat1/bin
# ./startup.sh