Note
I performed the integration via Terminal -> SSH on a Linux ( CentOS ) VPS.
Access your server via SSH.
ssh -p port_number username@hostname
Important
Replace
- "port_number" with the actual port for SSH.
- "username" with the actual username.
- "hostname" with the actual hostname.
Ensure your system is up to date.
sudo yum update -y
Install Java.
sudo yum install java-11-openjdk-devel -y
Important
You can install any desired version.
Verify the Java version.
java -version
Download and Install Apache Tomcat.
cd /tmp
curl -O https://downloads.apache.org/tomcat/tomcat-10/v10.1.0/bin/apache-tomcat-10.1.24.tar.gz
sudo mkdir /opt/tomcat
sudo tar xf apache-tomcat-10.1.24.tar.gz -C /opt/tomcat --strip-components=1
Ensure that the correct permissions are set.
sudo chmod -R 755 /opt/tomcat
Create a Tomcat User.
sudo groupadd user
Important
Replace 'user' with the desired username.
sudo useradd -M -s /bin/nologin -g user -d /opt/tomcat user
Important
Replace 'user' with the chosen username.
Create a Systemd Service File.
[Unit]
Description=Apache Tomcat Web Application Container
After=network.target
[Service]
Type=forking
User=tomcat
Group=tomcat
Environment="JAVA_HOME=/usr/lib/jvm/jre"
Environment="CATALINA_PID=/opt/tomcat/temp/tomcat.pid"
Environment="CATALINA_HOME=/opt/tomcat"
Environment="CATALINA_BASE=/opt/tomcat"
Environment="CATALINA_OPTS=-Xms512M -Xmx1024M -server -XX:+UseParallelGC"
Environment="JAVA_OPTS=-Djava.awt.headless=true -Djava.security.egd=file:/dev/./urandom"
ExecStart=/opt/tomcat/bin/startup.sh
ExecStop=/opt/tomcat/bin/shutdown.sh
[Install]
WantedBy=multi-user.target
Reload Systemd Manager Configuration.
sudo systemctl daemon-reload
Start Tomcat.
sudo systemctl start tomcat
Enable Tomcat Service to Start on Boot.
sudo systemctl enable tomcat
Open a specific Port (per your preference) in the Firewall settings.
sudo firewall-cmd --zone=public --permanent --add-port=8080/tcp
Important
Replace '8080' with the desired port.
Reload settings.
sudo firewall-cmd --reload
Edit the server.xml file located in the conf directory.
sudo nano /opt/tomcat/conf/server.xml
Ensure the following is present:
<?xml version="1.0" encoding="UTF-8"?>
<Server port={"8005"} shutdown="SHUTDOWN">
<Service name="Catalina">
<Connector port={"yourPort"} protocol="HTTP/1.1"
connectionTimeout="20000"
redirectPort={"8443"} />
<Engine name="Catalina" defaultHost={"yourHostnameOrIP"}>
<Host name={"yourHostnameOrIP"} appBase="webapps"
unpackWARs="true" autoDeploy="true">
<!-- You can add additional configurations here if needed -->
</Host>
</Engine>
</Service>
</Server>
Note
Replace the values in "{}" with the desired data.
Edit Tomcat Users Configuration File.
sudo nano /opt/tomcat/conf/tomcat-users.xml
Add the following lines inside.
<role rolename="manager-gui"/>
<role rolename="admin-gui"/>
<user username="admin" password="password" roles="manager-gui,admin-gui"/>
Important
Replace the username and password if you don't want to get rekt.
Restart.
sudo systemctl restart tomcat
sudo nano /etc/httpd/conf/httpd.conf
<VirtualHost *:80>
ServerName example.com
ServerAlias www.example.com
ProxyPass / https://yourHostnameOrIp:port/
ProxyPassReverse / https://yourHostnameOrIp:port/
</VirtualHost>