103Tomcat - amagerard/Wiki GitHub Wiki

HOME

Return to the list of wikis

RedHat/Xwiki

1- Network 2- Java 3- Tomcat 4- Mariadb 5- Xwiki
6- Nginx 7- selinux 8- GnomeShell 9 Troubleshoots

3. Tomcat

3.1 Create a system user that will run the Tomcat service.

groupadd tomcat
useradd -g tomcat -d /opt/tomcat tomcat

3.2 Installation Tomcat.

su - tomcat
wget -P /opt/tomcat https://dlcdn.apache.org/tomcat/tomcat-10/v10.1.36/bin/apache-tomcat-10.1.36.tar.gz

tar xzvf /opt/tomcat/apache-tomcat-10.1.36.tar.gz -C /opt/tomcat --strip-components=1
chmod +x /opt/tomcat/bin/*.sh
rm /opt/tomcat/apache-tomcat-10.1.36.tar.gz

echo "export CATALINA_HOME="/opt/tomcat/"" >> /opt/tomcat/.bashrc

Add
account: admin.
password: D51mbtAB49!.
at the end of the file before the last line </tomcat-users>.

vi /opt/tomcat/conf/tomcat-users.xml

-->  
<role rolename="manager-gui"/>  
<role rolename="admin-gui"/>  
<user username="admin" password="D51mbtAB49!" roles="manager-gui,admin-gui"/>  
</tomcat-users>  

Give the authorization to computers in the subnet 192.168.80.0/24
to access tomcat.

vi ./webapps/manager/META-INF/context.xml
vi ./webapps/host-manager/META-INF/context.xml
Add in the line "allow=" your subnet (example: 192.168.80.0/24).

<Valve className="org.apache.catalina.valves.RemoteAddrValve"  
allow="127\.\d+\.\d+\.\d+|::1|0:0:0:0:0:0:0:1|192\.168\.80\.\d+"/>  

exit

3.3 Create a Systemd startup file.

vi /etc/systemd/system/tomcat.service

# Systemd unit file for tomcat  
[Unit]  
Description=Apache Tomcat Web Application Container  
After=syslog.target network.target  
  
[Service]  
Type=forking  
  
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 -Xmx4096M -Xms4096M  -server -XX:+UseParallelGC'  
Environment='JAVA_OPTS=-Djava.awt.headless=true -Djava.security.egd=file:/dev/./urandom'  
  
ExecStart=/opt/tomcat/bin/startup.sh  
ExecStop=/bin/kill -15 $MAINPID  
  
User=tomcat  
Group=tomcat  
UMask=0007  
RestartSec=10  
Restart=always  
  
[Install]  
WantedBy=multi-user.target  

systemctl enable --now tomcat

3.4 Apache Tomcat/10.1.36.

From a computer in the subnet 192.168.80.0/24.
http://192.168.60.44:8080
From xwiki server.
http://localhost:8080

Click on Server Status:
username=admin
password=D51mbtAB49!