UpBrightSkills

Carving Future

Menu
  • AWS
  • Linux
  • IT Security
  • Wazuh
  • Windows
  • Docker
Menu

Automate Installation – Ubuntu with JDK & Tomcat

Posted on June 10, 2020February 2, 2024 by Admin

Update OS and Install required packages


apt-get update -y;
apt-get install gdebi -y;
apt-get install vim -y;
apt-get install nano -y;
apt-get install htop -y;
apt-get install unzip -y;
apt-get install python -y;

Install JDK

apt-get install default-jdk -y;
add-apt-repository ppa:webupd8team/java -y;
apt-get update -y;

Install Mysql | Kindly update password


sudo debconf-set-selections <<< 'mysql-server-5.7 mysql-server/root_password password password' 
sudo debconf-set-selections <<< 'mysql-server-5.7 mysql-server/root_password_again password password' 
apt-get -y install mysql-server-core-5.7 mysql-server-5.7 mysql-client-5.7;
service mysql start;

Install AWS CLI on Linux


curl "https://s3.amazonaws.com/aws-cli/awscli-bundle.zip" -o "awscli-bundle.zip"
unzip awscli-bundle.zip
./awscli-bundle/install -i /usr/local/aws -b /usr/local/bin/aws

Tomcat Installation (Update the Version which is required by your application)


groupadd tomcat
useradd -s /bin/false -g tomcat -d /opt/tomcat tomcat
cd /tmp/
curl -O http://redrockdigimark.com/apachemirror/tomcat/tomcat-8/v8.5.30/bin/apache-tomcat-8.5.30.tar.gz 
mkdir /opt/tomcat
tar xzvf apache-tomcat-8.5.30.tar.gz -C /opt/tomcat --strip-components=1
cd /opt/tomcat 
chgrp -R tomcat /opt/tomcat
chmod -R g+r conf
chmod g+x conf
chown -R tomcat webapps/ work/ temp/ logs/
update-java-alternatives -l

Create Service for Tomcat


touch /etc/systemd/system/tomcat.service
cd /etc/systemd/system/

Service File Update (File – /etc/systemd/system/tomcat.service)


cat <> tomcat.service;
[Unit]
Description=Apache Tomcat Web Application Container
After=network.target

[Service]
Type=forking

Environment=JAVA_HOME=/usr/lib/jvm/java-1.8.0-openjdk-amd64/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

User=tomcat
Group=tomcat
UMask=0007
RestartSec=10
Restart=always

[Install]
WantedBy=multi-user.target
EOF

Start Service


systemctl daemon-reload
systemctl start tomcat
systemctl enable tomcat

Add User for Tomcat Manager (Change your Username and Password as per your needs)


sed -i '22i\' /opt/tomcat/conf/tomcat-users.xml

Allow IP Address for Accessing Tomcat Manager App


cp /opt/tomcat/webapps/manager/META-INF/context.xml /opt/tomcat/webapps/manager/META-INF/context.orignal.xml
cp /opt/tomcat/webapps/host-manager/META-INF/context.xml /opt/tomcat/webapps/host-manager/META-INF/context.original.xml

Delete line number 19 to 21 (File – /opt/tomcat/webapps/manager/META-INF/context.xml)


sed -i '18,20d' /opt/tomcat/webapps/manager/META-INF/context.xml

Add below lines in between i.e 19,20 and 21 number. (File – /opt/tomcat/webapps/manager/META-INF/context.xml)


sed -i '18i\' /opt/tomcat/webapps/manager/META-INF/context.xml
sed -i '19i\'  /opt/tomcat/webapps/manager/META-INF/context.xml #kindly update IP Address

Delete line number 19 to 21 (File – /opt/tomcat/webapps/host-manager/META-INF/context.xml)


sed -i '18,20d' /opt/tomcat/webapps/host-manager/META-INF/context.xml

Add below lines in between i.e 18,19 and 20 number. (File – /opt/tomcat/webapps/host-manager/META-INF/context.xml)


sed -i '18i\' /opt/tomcat/webapps/host-manager/META-INF/context.xml
sed -i '19i\'  /opt/tomcat/webapps/host-manager/META-INF/context.xml #kindly update IP Address

Remove version string from HTTP error messages


cd /opt/tomcat/lib
jar xf catalina.jar /opt/tomcat/lib/org/apache/catalina/util/ServerInfo.properties
sed -i '16,17d' /opt/tomcat/lib/org/apache/catalina/util/ServerInfo.properties
sed -i '16i\server.info=Apache Tomcat' /opt/tomcat/lib/org/apache/catalina/util/ServerInfo.properties
jar uf catalina.jar org/apache/catalina/util/ServerInfo.properties
rm -rf /opt/tomcat/lib/org

Move unwanted Folders from WebApps Folder to Tmp


mv /opt/tomcat/webapps/examples /tmp
mv /opt/tomcat/webapps/docs /tmp

For More videos go to – https://www.youtube.com/channel/UCIUmpO3KBHPMtgzMA6p0IhA

Category: Linux

Recent Posts

  • Webhook Integration – Wazuh with Microsoft Teams
  • Migrate From CentOS 8 to Rocky Linux 8
  • AWS – How to Setup VPC with Public & Private Subnet
  • Install Magento on Ubuntu 18.04 with Nginx & Lets Encrypt Certificate
  • Wazuh – Setup File Integrity Monitoring

Recent Comments

    Tags

    automate AWS aws cloud bash script cloud compliance cyber awareness cyberawareness doccket email notification fileintegrity file integrity get started https integation it security itsecurity lamp stack lampstack lempstack lets encrypt letsencrypt linux magento nginx open source public & private subnet script secure networking security teams tomcat training for employees ubuntu vpc vulnerability vulnerability detection Wazuh webhook webhookintegration webserver

    Categories

    • AWS (1)
    • Docker (1)
    • IT Security (6)
    • Linux (6)
    • Wazuh (5)
    • Windows (1)

    Archives

    • February 2024
    • June 2021
    • August 2020
    • June 2020

    Recent Posts

    • Webhook Integration – Wazuh with Microsoft Teams
    • Migrate From CentOS 8 to Rocky Linux 8
    • AWS – How to Setup VPC with Public & Private Subnet
    • Install Magento on Ubuntu 18.04 with Nginx & Lets Encrypt Certificate
    • Wazuh – Setup File Integrity Monitoring

    Categories

    • AWS
    • Docker
    • IT Security
    • Linux
    • Wazuh
    • Windows
    © 2025 UpBrightSkills | Powered by Minimalist Blog WordPress Theme