Linux下配置Tomcat使用普通用户启动Daemon进程

系统环境
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   



  • 0
    点赞
  • 1
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值