If you do have the JDK installed, you can skip to: Step 2: Download and Install the apache-tomcat-7.0.30
–>
# Get the aliases and functions
if [ -f ~/.bashrc ]; then
. ~/.bashrc
fi
# User specific environment and startup programs
JAVA_HOME=/usr/java/jdk1.7.0_17/
export JAVA_HOME
PATH=$JAVA_HOME/bin:$PATH
export PATH
#PATH=$PATH:$HOME/bin
#export PATH
/usr/java/jdk1.7.0_17/
# description: Tomcat Start Stop Restart
# processname: tomcat
JAVA_HOME=/usr/java/jdk1.7.0_17
export JAVA_HOME
PATH=$JAVA_HOME/bin:$PATH
export PATH
CATALINA_HOME=/usr/share/apache-tomcat-7.0.30
case $1 in
start)
sh $CATALINA_HOME/bin/startup.sh
;;
stop)
sh $CATALINA_HOME/bin/shutdown.sh
;;
restart)
sh $CATALINA_HOME/bin/shutdown.sh
sh $CATALINA_HOME/bin/startup.sh
;;
esac
exit 0
[root@station1 ~]# chkconfig –level 234 tomcat on
tomcat 0:off 1:off 2:on 3:on 4:on 5:off 6:off
Using CATALINA_BASE: /usr/share/apache-tomcat-7.0.30
Using CATALINA_HOME: /usr/share/apache-tomcat-7.0.30
Using CATALINA_TMPDIR: /usr/share/apache-tomcat-7.0.30/temp
Using JRE_HOME: /usr/java/jdk1.7.0_17
Using CLASSPATH: /usr/share/apache-tomcat-7.0.30/bin/bootstrap.jar:/usr/share/apache-tomcat-7.0.30/bin/tomcat-juli.jar
[root@station1 ~]# service tomcat start
Using CATALINA_BASE: /usr/share/apache-tomcat-7.0.30
Using CATALINA_HOME: /usr/share/apache-tomcat-7.0.30
Using CATALINA_TMPDIR: /usr/share/apache-tomcat-7.0.30/temp
Using JRE_HOME: /usr/java/jdk1.7.0_17
Using CLASSPATH: /usr/share/apache-tomcat-7.0.30/bin/bootstrap.jar:/usr/share/apache-tomcat-7.0.30/bin/tomcat-juli.jar
[root@station1 ~]# service tomcat restart
Using CATALINA_BASE: /usr/share/apache-tomcat-7.0.30
Using CATALINA_HOME: /usr/share/apache-tomcat-7.0.30
Using CATALINA_TMPDIR: /usr/share/apache-tomcat-7.0.30/temp
Using JRE_HOME: /usr/java/jdk1.7.0_17
Using CLASSPATH: /usr/share/apache-tomcat-7.0.30/bin/bootstrap.jar:/usr/share/apache-tomcat-7.0.30/bin/tomcat-juli.jar
Using CATALINA_BASE: /usr/share/apache-tomcat-7.0.30
Using CATALINA_HOME: /usr/share/apache-tomcat-7.0.30
Using CATALINA_TMPDIR: /usr/share/apache-tomcat-7.0.30/temp
Using JRE_HOME: /usr/java/jdk1.7.0_07
Using CLASSPATH: /usr/share/apache-tomcat-7.0.30/bin/bootstrap.jar:/usr/share/apache-tomcat-7.0.30/bin/tomcat-juli.jar
For security reasons, it is always best to run services with the only those privileges that are necessary.
There are some who make a strong case that this is not required, but it’s always best to err on the side of caution.
To run Tomcat as non-root user, we need to do the following:
1. Create the group ‘tomcat’:
# description: Tomcat Start Stop Restart
# processname: tomcat
export JAVA_HOME
PATH=$JAVA_HOME/bin:$PATH
export PATH
CATALINA_HOME=/usr/share/apache-tomcat-7.0.30
case $1 in
start)
/bin/su sh $CATALINA_HOME/bin/startup.sh
;;
stop)
/bin/su sh $CATALINA_HOME/bin/shutdown.sh
;;
restart)
/bin/su sh $CATALINA_HOME/bin/shutdown.sh
/bin/su sh $CATALINA_HOME/bin/startup.sh
;;
esac
exit 0
To run services below port 1024 as a user other than root, you can add the following to your IP tables
While Tomcat has improved it’s ‘standalone performance’, I still prefer to have Apace in front of it for a number of reasons.
In your Apache config, be sure to set KeepAlive to ‘on’. Apache tuning, of course, is a whole subject in itself…
ServerAdmin tomcat@vn.tips4admin.com
ServerName vn.tips4admin.com
ServerAlias www.vn.tips4admin.com
ProxyRequests Off
ProxyPreserveHost On
<Proxy *>
Order allow,deny
Allow from all
</Proxy>
ProxyPass / http://127.0.0.1:8080/
ProxyPassReverse / http://s127.0.0.1:8080/
ErrorLog logs/error_log
CustomLog logs/access_log common
</VirtualHost>