添加tomcat用户组
/usr/sbin/groupadd tomcat
添加tomcat用户,并限制登录
/usr/sbin/useradd -s /bin/bash -g tomcat tomcat
/usr/sbin/usermod -L tomcat #锁定密码,使密码无效
修改目录所有者:
#chown -R tomcat:tomcat /usr/local/tomcat
#vi /etc/init.d/tomcat
#!/bin/bash # description: Startup Script for tomcat # /etc/rc.d/init.d/tomcat #JDK Settings export JAVA_HOME=/usr/local/jdk1.8.0_60 ###根据需要修改此处 export CLASSPATH=$JAVA_HOME/lib/dt.jar:$JAVA_HOME/lib/tools.jar:$JAVA_HOME/jre/lib/rt.jar export PATH=$PATH:$JAVA_HOME/bin case "$1" in start) echo "Starting tomcat: " #以tomcat用户身份运行 根据需要修改此处 su -c /usr/local/tomcat/bin/./startup.sh tomcat echo "OK......tomcat started" ;; stop) echo "Shutdown tomcat: " /usr/local/tomcat/bin/./shutdown.sh echo "OK.....tomcat stoped" ;; *) echo "Usage: ‘basename $0‘ start|stop" exit 1 esac exit 0
给启动命令执行权限
chmod 777 /etc/init.d/tomcat
启动tomcat
/etc/init.d/tomcat start
关闭tomcat
/etc/init.d/tomcat stop
时间: 2024-10-01 07:20:57