Saturday, January 16, 2021

Setting up Tomcat 9.0.41 && mariadb-server 10.5 on Debian Bullseye/sid

Setup Tomcat via original tar.gz ball  and JDK 11 allow to deploy "war" archive been built for Web Servlet Application from  http://lxer.com/module/newswire/view/295844/index.html . Thus CRUD Server side Java Apps might be moved oDebian Bullseye/sid in 3-5 minutes .

Creating account tomcat && download tar.gz ball 

$ sudo apt install default-jdk

$ sudo groupadd --system tomcat 

$ sudo useradd -d /opt/tomcat -r -s /bin/false -g tomcat tomcat

$ sudo apt -y install wget

$ export VER="9.0.41"

$ wget https://archive.apache.org/dist/tomcat/tomcat-9/v${VER}/bin/apache-tomcat-${VER}.tar.gz

Extracting tar.gz ball  to $HOME folder of tomcat

$ sudo mkdir /opt/tomcat

$ sudo tar xzvf apache-tomcat-9*tar.gz -C /opt/tomcat --strip-components=1

$ cd /opt/tomcat

$ sudo chown -R tomcat /opt/tomcat

$ sudo chmod -R g+r conf

$ sudo chmod g+x conf

$ sudo update-java-alternatives -l

java-1.11.0-openjdk-amd64 1111 /usr/lib/jvm/java-1.11.0-openjdk-amd64

 Creating Tomcat’s systemd service unit :-

 $ sudo vi /etc/systemd/system/tomcat.service

[Unit]

Description=Apache Tomcat Web Application Container

After=network.target

[Service]

Type=forking

Environment=JAVA_HOME=/usr/lib/jvm/java-1.11.0-openjdk-amd64

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

User=tomcat

Group=tomcat

UMask=0007

RestartSec=10

Restart=always

[Install]

WantedBy=multi-user.target

Next

$ sudo systemctl daemon-reload

$ sudo systemctl start tomcat

$ sudo systemctl enable tomcat

Open port 8080 

$ sudo apt install ufw -y

$ sudo ufw allow 8080

Grant permissions to admin 

Update $CATALINA_HOME/conf/tom-users.xml

<tomcat-users>

. . .

    <user username="admin" password="password" roles="manager-gui,admin-gui"/>

</tomcat-users>

Update context.xml files under Tomcat’s  webapps  ( for remote access ) 

 <Context antiResourceLocking="false" privileged="true" >

  <!--<Valve className="org.apache.catalina.valves.RemoteAddrValve"

         allow="127\.\d+\.\d+\.\d+|::1|0:0:0:0:0:0:0:1" />-->

</Context>

$ sudo systemctl restart tomcat

`sudo apt install mariadb-server`  installs version 10.5 of mariadb on Debian Testing


No comments:

Post a Comment