介绍
linux环境下,tomcat下载、配置权限、服务
官网地址: https://tomcat.apache.org/download-80.cgi
下载
wget https://dlcdn.apache.org/tomcat/tomcat-8/v8.5.100/bin/apache-tomcat-8.5.100.tar.gz
解压
tar -xf apache-tomcat-8.5.100.tar.gz -C /www
改文件夹名称
cd /www
mv apache-tomcat-8.5.100 apache-tomcat-8.5
加运行账户
groupadd tomcat
useradd -s /sbin/nologin -g tomcat -d /www/apache-tomcat-8.5 tomcat
passwd tomcat
设置文件夹权限
chown -R tomcat.tomcat /www/apache-tomcat-8.5
设置为服务
vi /etc/systemd/system/tomcat.service
# Systemd unit file for tomcat
[Unit]
Description=Apache Tomcat Web Application Container
After=syslog.target network.target
[Service]
Type=forking
User=tomcat
Group=tomcat
Environment=JAVA_HOME=/www/jdk/jre
Environment=CATALINA_PID=/www/apache-tomcat-8.5/temp/tomcat.pid
Environment=CATALINA_HOME=/www/apache-tomcat-8.5
Environment=CATALINA_BASE=/www/apache-tomcat-8.5
Environment=CATALINA_OPTS=
Environment="JAVA_OPTS=-Dfile.encoding=UTF-8 -Dnet.sf.ehcache.skipUpdateCheck=true \
-XX:+UseConcMarkSweepGC -XX:+CMSClassUnloadingEnabled \
-XX:+UseParNewGC -Xms256m -Xmx4096m"
ExecStart=/www/apache-tomcat-8.5/bin/startup.sh
ExecStop=/bin/kill -15 $MAINPID
[Install]
WantedBy=multi-user.target
重新加载 systemd 的守护进程配置
systemctl daemon-reload
启用服务
systemctl enable tomcat.service
禁用服务
systemctl disable tomcat.service
启动tomcat
systemctl start tomcat.service
停止tomcat
systemctl stop tomcat.service