CentOS7 + OpenJDK11 + Tomcat9 動作環境構築

# Javaインストール
yum install java-11-openjdk
yum install java-11-openjdk-devel
確認
# java -version
openjdk version “11.0.2” 2019-01-15 LTS
OpenJDK Runtime Environment 18.9 (build 11.0.2+7-LTS)
OpenJDK 64-Bit Server VM 18.9 (build 11.0.2+7-LTS, mixed mode, sharing)
OpenJDKのインストールパス
/usr/lib/jvm/java-11-openjdk-11.0.2.7-0.el7_6.x86_64
# Tomcatインストール
wget https://www-eu.apache.org/dist/tomcat/tomcat-9/v9.0.16/bin/apache-tomcat-9.0.16.zip
useradd -s /sbin/nologin tomcat
mv apache-tomcat-9.0.16 /usr/local/
ln -s apache-tomcat-9.0.16/ /usr/local/tomcat
# 環境変数の設定
vi /etc/profile
ファイルの末尾に以下を追記
JAVA_HOME=/usr/lib/jvm/java-11-openjdk-11.0.2.7-0.el7_6.x86_64
CATALINA_HOME=/usr/local/tomcat
export JAVA_HOME CATALINA_HOME
反映
source /etc/profile
確認
echo $JAVA_HOME
/usr/lib/jvm/java-11-openjdk-11.0.2.7-0.el7_6.x86_64
echo $CATALINA_HOME
/usr/local/tomcat
# Tomcat 自動起動設定
vi /etc/systemd/system/tomcat.service
以下の内容を記述
[Unit]
Description=Apache Tomcat
After=syslog.target network.target
[Service]
User=tomcat
Group=tomcat
Type=oneshot
Type=forking
PIDFile=/usr/local/tomcat/tomcat.pid
#EnvironmentFile=/etc/sysconfig/tomcat
ExecStart=/usr/local/tomcat/bin/startup.sh
ExecStop=/usr/local/tomcat/bin/shutdown.sh
Environment=’CATALINA_OPTS=-Xms512M -Xmx512M -server -XX:+UseParallelGC’
Environment=’JAVA_OPTS=-Djava.awt.headless=true -Djava.security.egd=file:/dev/./urandom’
KillMode=none
[Install]
WantedBy=multi-user.target
chmod 755 /etc/systemd/system/tomcat.service
chown -R tomcat:tomcat /usr/local/tomcat/
systemctl daemon-reload
systemctl start tomcat

コメント

タイトルとURLをコピーしました