系统环境
System Version:略(任意系统版本均可)
Tomcat Version: 6.0.41
JRE/JDK Version: 1.6
安装配置Tomcat
过程略,具体可参考我之前的文章,整个配置过程大致一样,除启动脚本配置不一样外,具体配置如下
配置Daemon方式启动tomcat
原因不多说,按前面文章方式肯定是因为直接用root用户启动tomcat不安全,所以才打算使用普通用户启动
1.创建专用启动用户
# useradd -M -r -d /dev/null -s /sbin/nologin tomcat
2.编译jsvc
# cd /opt/tomcat/bin
# tar -xf commons-daemon-native.tar.gz
# cd commons-daemon-1.0.15-native-src/unix
# ls
CHANGES.txt configure configure.in INSTALL.txt Makedefs.in Makefile.in man native support
# sh support/buildconf.sh
# ./configure --with-java=/opt/jdk #--with-java=/opt/jdk 这个是指定jdk的具体路径,因为编译jsvc需要用到jdk,正式生产环境建议编译完成后删除jdk,java环境使用jre即可
# make
# cp jsvc /opt/tomcat/bin/
# cd /opt/tomcat/bin/
# rm -fr commons-daemon-1.0.15-native-src
3.配置jsvc的daemon启动脚本
# cp daemon.sh /etc/init.d/tomcat
# vim /etc/init.d/tomcat
在文件头增加以下环境变量(注:在启动脚本中增加这几个环境变量,是为了在系统启动时能正常启动这个脚本)
export JAVA_HOME=/opt/jre
export TOMCAT_HOME=/opt/tomcat
export CATALINA_HOME=/opt/tomcat
export CATALINA_BASE=/opt/tomcat
export CATALINA_TMPDIR=/opt/tomcat/temp
如果是其它专用启动用户
# Use the maximum available, or set MAX_FD != -1 to use that
test ".$MAX_FD" = . && MAX_FD="maximum"
# Setup parameters for running the jsvc
#
test ".$TOMCAT_USER" = . && TOMCAT_USER=tomcat #在这个地方把用户名改了
# Set JAVA_HOME to working JDK or JRE
JAVA_HOME=/opt/jre
# If not set we'll try to guess the JAVA_HOME
# from java binary if on the PATH
#
4.启动脚本
# /etc/init.d/tomcat start
检查是否有启动成功
# netstat -ntpul
Active Internet connections (only servers)
Proto Recv-Q Send-Q Local Address Foreign Address State PID/Program name
tcp 0 0 ::ffff:127.0.0.1:8080 :::* LISTEN 3059/jsvc.exec
tcp 0 0 ::ffff:127.0.0.1:8009 :::* LISTEN 3059/jsvc.exec
阅读(1455) | 评论(0) | 转发(0) |