CentOS7にtomcat8.5をインストールする方法
1.ユーザー作成
#useradd -s /sbin/nologin tomcat
2.tomcatファイル展開&配置
#tar zxvf apache-tomcat-8.5.37.tar.gz
#mv apache-tomcat-8.5.37 /opt/
#chown -R tomcat. /opt/apache-tomcat-8.5.37
3.シンボリックリンクを設定
#ln -s /opt/apache-tomcat-8.5.37/opt/tomcat
環境反映
#echo 'export CATALINA_HOME=/opt/tomcat’ > /etc/profile.d/tomcat.sh
#source /etc/profile.d/tomcat.sh
4.tomcat初期設定
#vim /etc/systemd/system/tomcat.service
設定内容
[Unit]
Description=Apache Tomcat 8
After=syslog.target network.target
[Service]
User=tomcat
Group=tomcat
Type=oneshot
PIDFile=/opt/tomcat/tomcat.pid
RemainAfterExit=yes
ExecStart=/opt/tomcat/bin/startup.sh
ExecStop=/opt/tomcat/bin/shutdown.sh
ExecReStart=/opt/tomcat/bin/shutdown.sh;/opt/tomcat/bin/startup.sh
[Install]
WantedBy=multi-user.target
5.Tomcat起動
#chmod 755 /etc/systemd/system/tomcat.service
#systemctl start tomcat