#set java JDK JAVA_HOME=/usr/local/jdk1.6.0_03/ JRE_HOME=/usr/local/jdk1.6.0_03/jre/ PATH=$PATH:$JAVA_HOME/bin:$JRE_home/bin CLASSPATH=$JAVA_HOME/lib/tools.jar:$JAVA_HOME/lib/dt.jar export JAVA_HOME export JRE_HOME export PATH export CLASSPATH
5.Tomcat自动启动脚本
- #!/bin/bash
- # chkconfig: 2345 10 90
- # description: Starts and Stops the Tomcat daemon.
- TOMCAT_HOME=/usr/local/tomcat7 #tomcat目录
- TOMCAT_START=$TOMCAT_HOME/bin/startup.sh
- TOMCAT_STOP=$TOMCAT_HOME/bin/shutdown.sh
- # necessary environment variables export
- CATALINA_HOME=$TOMCAT_HOME
- export JAVA_HOME=/usr/local/jdk1.6.0_03/ #JDK目录
- # source function library.
- . /etc/rc.d/init.d/functions
- # check that networking is up.
- [ "${NETWORKING}" = "no" ] && exit 0
- # check for tomcat script
- if [ ! -f $TOMCAT_HOME/bin/catalina.sh ]; then
- echo "Tomcat not valilable..."
- exit
- fi
- start(){
- echo -n "Starting Tomcat: "
- daemon $TOMCAT_START
- echo
- touch /var/lock/subsys/tomcat
- }
- stop(){
- echo -n $"Shutting down Tomcat: "
- daemon $TOMCAT_STOP
- rm -f /var/lock/subsys/tomcat.pid echo
- }
- restart(){
- stop
- start
- }
- status(){
- ps ax --width=1000 | grep "[o]rg.apache.catalina.startup.Bootstrap start" \
- | awk '{printf $1 " "}' | wc | awk '{print $2}' > /tmp/tomcat_process_count.txt
- read line < /tmp/tomcat_process_count.txt
- if [ $line -gt 0 ]; then
- echo -n "tomcat ( pid "
- ps ax --width=1000 | grep "org.apache.catalina.startup.Bootstrap \
- start" | awk '{printf $1 " "}'
- echo -n ") is running..."
- echo
- else
- echo "Tomcat is stopped"
- fi
- }
- case "$1" in
- start)
- start ;;
- stop)
- stop ;;
- restart)
- stop
- sleep 3
- start ;;
- status)
- status ;;
- *)
- echo "Usage: tomcatd {start|stop|restart|status}"
- exit 1
- esac
- exit 0
将脚本文件保存在/etc/init.d中,命名为tomcat
[root@web ~]# chmod +x /etc/init.d/tomcat
[root@web ~]# chkconfig --add tomcat
- <tomcat-users>
- <role rolename="tomcat"/>
- <role rolename="role1"/>
- <user username="tomcat" password="tomcat" roles="tomcat"/>
- <user username="both" password="tomcat" roles="tomcat,role1"/>
- <user username="role1" password="tomcat" roles="role1"/>
- <role rolename="manager-gui"/>
- <user username="admin" password="abc123" roles="manager-gui"/> #加入的行
- </tomcat-users>
打开管理页面:http://192.168.209.129:8080/manager/html
2.虚拟主机
- <Host name="web1.example.com" appBase="webapps1"
- unpackWARs="true" autoDeploy="true">
- <Valve className="org.apache.catalina.valves.AccessLogValve" directory="logs"
- prefix="web1_access_log." suffix=".txt"
- pattern="%h %l %u %t "%r" %s %b" />
- </Host>
- LoadModule jk_module modules/mod_jk.so
- Include /usr/local/apache2/conf/mod_jk.conf
- # Where to find workers.properties
- JkWorkersFile /usr/local/apache2/conf/workers.properties
- # Where to put jk logs
- JkLogFile /usr/local/apache2/logs/mod_jk.log
- # Set the jk log level [debug/error/info]
- JkLogLevel info
- # Select the log format
- JkLogStampFormat "[%a %b %d %H:%M:%S %Y]"
- # JkRequestLogFormat set the request format
- JkRequestLogFormat "%w %V %T"
- # JkOptions indicate to send SSL KEY SIZE,
- JkOptions +ForwardKeySize +ForwardURICompat -ForwardDirectories
- # Send JSPs for context /examples to worker named worker
- JkMount /*.jsp worker1
- JkMount /servlet/* worker1
- # Define 1 real worker using ajp13
- worker.list=worker1
- # Set properties for worker1 (ajp13)
- worker.worker1.type=ajp13
- worker.worker1.host=localhost
- worker.worker1.port=8009
- worker.worker1.lbfactor=50
- worker.worker1.cachesize=10
- worker.worker1.cache_timeout=600
- worker.worker1.socket_keepalive=1
- worker.worker1.socket_timeout=300
- <Context path="" docBase="/var/www/html" debug="0" reloadable="true" crossContext="true"/>
- <%@page language="java"%>
- 100+200=<%=100+200%>