tomcat8权限分离

时间:2023-03-08 17:37:34

安装jdk

tar xf jdk-8u121-linux-x64.tar.gz

mv jdk-*  /usr/local/jdk1.8

vi /etc/profile

export JAVA_HOME=/usr/local/jdk1.8
export PATH=$JAVA_HOME/bin:$PATH
export CLASSPATH=.:$JAVA_HOME/lib/dt.jar:$JAVA_HOME/lib/tools.jar

source  /etc/profile

# java -version
java version "1.8.0_121"
Java(TM) SE Runtime Environment (build 1.8.0_121-b13)
Java HotSpot(TM) 64-Bit Server VM (build 25.121-b13, mixed mode)

tar xf apache-tomcat-8.5.12.tar.gz

mv apache-tomcat-* /usr/local/tomcat8

cd /usr/local/tomcat8/bin

tar xf commons-daemon-native.tar.gz

cd commons-daemon-native-src/unix

./configure

make    # make后,会在当前文件夹下生成一个名为 jsvc的文件,将其复制到$CATALINA_HOME/bin目录

cp jsvc ../../

useradd tomcat -M -d / -s /usr/sbin/nologin

cd ../../  # 回到$CATALINA_HOME/bin目录下

# 接下来便是修改$CATALINA_HOME/bin目录下的 daemon.sh 文件
# 设置其中的TOMCAT_USER=tomcat,JAVA_HOME=/usr/local/jdk1.8
test ".$TOMCAT_USER" = . && TOMCAT_USER=tomcat
JAVA_HOME=/usr/local/jdk1.8
# 如果$CATALINA_HOME/bin下的*.sh文件没有运行权限,则为其添加运行权限 chmod +x *.sh # 设置$CATALINE_HOME文件夹及其所有子文件Owner为tomcat chown -R tomcat:tomcat /usr/local/apache-tomcat-8 # 启动Tomcat daemon.sh start
ln -s /usr/local/tomcat8/bin/daemon.sh /etc/init.d/tomcat8
/etc/init.d/tomcat8 start