I wanted an application server for JAVA,
As a memorandum when building the environment of CentOS7 in Sakura Cloud, I will summarize it.
First, update the package
# yum update
Steps to install Apache
# yum -y install httpd # service httpd start <-Start Apache # firewall-cmd --list-ports <-Check the currently available ports. # firewall-cmd --add-service = http ← Open the web server service (port). # firewall-cmd --permanent --add-service = http ← Set to open even if the web server service (port) is restarted. # chkconfig httpd on ← Apache is set to "Auto start"
To install Oracle's JDK 8
# yum search openjdk # yum install java-1.8.0-openjdk # java -version
How to install Apache Tomcat 8 on CentOS 7
# useradd -s /sbin/nologin tomcat ← ユーザーの追加 # cd ~ ← ルート直下に移動 # curl -O http://ftp.kddilabs.jp/infosystems/apache/tomcat/tomcat-8/v8.5.11/bin/apache-tomcat-8.5.11.tar.gz ← ここからインストール # tar -xzvf ~/apache-tomcat-8.5.11.tar.gz # mv ~/apache-tomcat-8.5.11 /opt # chown -R tomcat:tomcat /opt/apache-tomcat-8.5.11
Creating and registering services
From CentOS 7, the service is managed by systemd. Here, Apache Tomcat 8 is registered as a service. First, create a new /etc/systemd/system/tomcat.service and save it as follows. This is the service definition file.
[Unit] Description = Apache Tomcat 8 After = network.target [Service] User = tomcat Group = tomcat Type = oneshot PIDFile = / opt / apache-tomcat-8.5.11 / tomcat.pid RemainAfterExit = yes ExecStart = / opt / apache -tomcat-8.5.11 / bin / startup.sh ExecStop = / opt / apache-tomcat-8.5.11 / bin / shutdown.sh ExecReStart = / opt / apache-tomcat-8.5.11 / bin / shutdown.sh; / opt / apache-tomcat-8.5.11 / bin / startup.sh [Install] WantedBy = multi-user.target
Then register for the service.
# chmod 755 /etc/systemd/system/tomcat.service # systemctl enable tomcat # ln -s '/etc/systemd/system/tomcat.service' '/etc/systemd/system/multi-user.target.wants/tomcat.service'
Starting and stopping Apache Tomcat 8
# systemctl start tomcat # systemctl stop tomcat
Link Apache2.4 and Tomcat8
Tomcat also has a function as an HTTP server, but HTTP requests are received by Apache, and Apache is set to return the results processed by Tomcat.
The transfer between Apache and Tomcat is done by the mod_proxy_ajp module.
Apache settings (00-proxy.conf)
Check if ajp is set in "00-proxy.conf" in /etc/httpd/conf.modules.d/.
Check if the following two lines exist in the "00-proxy.conf" file.
LoadModule proxy_module modules / mod_proxy.so LoadModule proxy_ajp_module modules / mod_proxy_ajp.so
Create a proxy-ajp.conf setting when there is a request for a servlet in the /etc/httpd/conf.d/ directory. For example, if there is a request to "http: // domain name / docs /", set "docs" on the Tomcat side as follows.
<Location / docs />
ProxyPass ajp: //127.0.0.1: 8009 / docs /
</ Location>
Confirmation and setting on Tomcat side
Next, configure Tomcat.
Check if the following settings are in /opt/apache-tomcat-8.0.32/conf/server.xml.
<Connector port = "8009" protocol = "AJP / 1.3" redirectPort = "8443" />
Since the default Tomcat port (port number 8080) is enabled, comment out the following settings.
--><!-<Connector port = "8080" protocol = "HTTP / 1.1" connectionTimeout = "20000" redirectPort = "8443" />->
Reboot
# service httpd restart
This completes the Tomcat setup.
[…] Summary of Apache and Tomcat environment construction with Sakura Cloud CentOS7 […]
Since there was no memory setting, you may want to refer to this site.
How to install Tomcat
https://ti-tomo-knowledge.hatenablog.com/entry/2018/07/05/141158