标签:container apache des 自启动 esc sys ali pac daemon
1.首先添加不能登陆的用户及组
groupadd tomcat
useradd -r -g tomcat -s /sbin/nologin tomcat
2.安装openJDK并设置好JAVA_HOME环境变量
3.解压tomcat文件
tar -xzvf tomcat-version.tar.gz -C /usr/local
cd /user/local
mv tomcat-version tomcat
cd tomcat/bin
tar xvfz commons-daemon-native.tar.gz
cd commons-daemon-1.1.x-native-src/unix
./configure
make
cp jsvc ../..
cd ../..
4.添加systemd服务单元,添加tomcat为自启动服务
vi /etc/systemd/system/tomcat.service
添加如下内容
[Unit]
Description=Apache Tomcat Web Application Container
After=network.target remote-fs.target nss-lookup.target
[Service]
Type=forking
Environment=JAVA_HOME=/usr/lib/jvm/java
Environment=CATALINA_HOME=/usr/local/tomcat
Environment=CATALINA_BASE=/usr/local/tomcat
ExecStart=/usr/local/tomcat/bin/daemon.sh start
ExecStop=/usr/local/tomcat/bin/daemon.sh stop
[Install]
WantedBy=multi-user.target
再运行:
systemctl daemon-reload
systemctl enable tomcat
systemctl start tomcat
systemctl status tomcat
注:
可以不用在tomcat.service中声明JAVA_HOME,CATALINA_BASE,CATALINA_HOME变量,也可以在tomcat安装目录的bin下的daemon.sh文件的首行声明(即:在# OS specific support (must be ‘true‘ or ‘false‘).前一行)
systemd的脚本不会从/etc/profile中读取环境变量
记得开启防火墙及8080端口
标签:container apache des 自启动 esc sys ali pac daemon
原文地址:https://www.cnblogs.com/wjsffzb/p/9551667.html