CentOS7にTomcat8をインストールする方法

1.tomcatユーザー作成
#useradd -s /sbin/nologin tomcat

2.tomcatファイル展開
#mkdir -p /usr/local/src/tomcat
#cd /usr/local/src/tomcat
#tar zxvf apache-tomcat-8.5.9.tar.gz
#mv apache-tomcat-8.5.9 /opt/
#chown -R tomcat. /opt/apache-tomcat-8.5.9

シンボリック設定
#ln -s /opt/apache-tomcat-8.5.9 /opt/tomcat

パスを設定
#echo 'export CATALINA_HOME=/opt/tomcat’ > /etc/profile.d/tomcat.sh
#source /etc/profile.d/tomcat.sh

3.tomcat.service定義
#vim /etc/systemd/system/tomcat.service
/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

4.権限設定
#chmod 755 /etc/systemd/system/tomcat.service

5.起動
#systemctl start tomcat

停止
#systemctl start tomcat

再起動
#systemctl restart tomcat

Linux

Posted by arkgame