Tomcatを起動しようと systemctl start したところ失敗。
# systemctl start tomcat Job for tomcat.service failed because the control process exited with error code. See "systemctl status tomcat.service" and "journalctl -xe" for details.
よくわからないので journalctl -xe で確認してみたところ、JAVA_HOME のパスが設定されていないとエラーが出てました。ただ、先に実施したJavaのインストールではパスを通しているので???という感じです。
# journalctl -xe 1月 23 11:37:40 hogeoreman.local systemd[1]: Starting Apache Tomcat 6... -- Subject: Unit tomcat.service has begun start-up -- Defined-By: systemd -- Support: http://lists.freedesktop.org/mailman/listinfo/systemd-devel -- -- Unit tomcat.service has begun starting up. 1月 23 11:37:40 hogeoreman.local startup.sh[7118]: Neither the JAVA_HOME nor the JRE_HOME environment variable is d 1月 23 11:37:40 hogeoreman.local startup.sh[7118]: At least one of these environment variable is needed to run this 1月 23 11:37:40 hogeoreman.local systemd[1]: tomcat.service: main process exited, code=exited, status=1/FAILURE 1月 23 11:37:40 hogeoreman.local systemd[1]: Failed to start Apache Tomcat 6.
どうやら、systemctl では bash_profile に設定した環境変数を読み込まないみたい。まぁよく考えたらそりゃそうですよね。
というわけで、Tomcatの場合は setenv.sh というファイルを bin ディレクトリに作成すれば読み込んでくれるようなので下記のように作成してみました。
# vi /usr/local/tomcat6/bin/setenv.sh
下記を記載します。
export JAVA_HOME=/usr/java/ export PATH=$JAVA_HOME/bin:$PATH export CATALINA_HOME=/usr/local/tomcat6/
これで完了。
再度 systemctl をリロードして start したところ、無事に起動できました!
# systemctl daemon-reload # systemctl start tomcat # systemctl status tomcat ● tomcat.service - Apache Tomcat 6 Loaded: loaded (/etc/systemd/system/tomcat.service; enabled; vendor preset: disabled) Active: active (exited) since 木 2020-01-23 11:40:16 JST; 2s ago
これで解決です。