A memo when building Tomcat, which everyone loves as a Java application server, on CentOS 7 without yum. Unless you have a specific reason, I think it's faster to use yum.
Added tomcat user (username can be anything but easy to understand)
[root@localhost ]# useradd tomcat
[root@localhost ]# passwd tomcat
Download the JDK rpm from the URL below http://www.oracle.com/technetwork/java/javase/downloads/jdk8-downloads-2133151.html
Bring the dropped .rpm to the target server
[root@localhost ]# yum localinstall jdk-8u111-linux-x64.rpm
#root and tomcat.bash_export to profile JAVA_HOME=/usr/Java/jdk1.8.0_111/jre/Added
Drop the binary from tomcat official and unzip => change owner / group In the example below, it is placed in / opt, but you can use any path you like.
[root@localhost ]# wget http://ftp.jaist.ac.jp/pub/apache/tomcat/tomcat-8/v8.5.6/bin/apache-tomcat-8.0.39.tar.gz
[root@localhost ]# tar xzvf apache-tomcat-8.0.39.tar.gz
[root@localhost ]# mv apache-tomcat-8.0.39 /opt/tomcat
[root@localhost ]# cd /opt/
[root@localhost ]# chown -R tomcat:tomcat tomcat
You need to manually create / register this area, which yum will do automatically.
[root@localhost ]# vim /etc/systemd/system/tomcat.service
[Unit]
Description=Apache Tomcat 8
After=network.target
[Service]
User=tomcat
Type=forking
EnvironmentFile=/etc/sysconfig/tomcat
KillMode=none
ExecStart=/opt/tomcat/bin/startup.sh
ExecStop=/opt/tomcat/bin/shutdown.sh
[Install]
WantedBy=multi-user.target
[root@localhost ]# vim /etc/sysconfig/tomcat
Java_HOME="/usr/Java/jdk1.8.0_111/jre/"
Java_OPTS="-DJava.security.egd=file:/dev/./urandom"
[root@localhost ]# systemctl daemon-reload
If you do not use firewalld for verification purposes, skip it and OK
[root@localhost ]# vim /usr/lib/firewalld/services/tomcat.xml
<service>
<short>WWW (HTTP-tomcat)</short>
<description>HTTP is the protocol used to serve Web pages. If you plan to make your Web server publicly available, enable this option. This option is not required for viewing pages locally or developing Web pages.</description>
<port protocol="tcp" port="8080"/>
</service>
[root@localhost ]# systemctl restart firewalld
[root@localhost ]# firewall-cmd --add-service=tomcat --zone=public --permanent
success
[root@localhost ]# systemctl restart firewalld
First, start Tomcat. Also, make sure that the service starts automatically when the OS starts.
[root@localhost ]# systemctl enable tomcat
[root@localhost ]# systemctl start tomcat
[root@localhost ]# systemctl status tomcat
[root@localhost ]# ss -nat | grep 8080
LISTEN 0 100 :::8080 :::*
Access http: // [ip_addr]: 8080 with a web browser, and when the familiar tomcat top page is displayed, it's OK.
Recommended Posts