A Step by Step Guide to Installing Apache Tomcat 9 Linux

intalling 9 Linux

Apache Tomcat is required if you wish to host or create Java web applications. How to installing Apache Tomcat 9 on Linux is shown here.

Java programmes can operate on Apache Tomcat, an open-source web server and servlet container. It is the most widely used application server for web applications written in Java.

download 5

It is used by hundreds of businesses, including MIT, Alibaba, and eBay.

Apache Tomcat 9 prerequisites

You must have sudo capabilities as a user. To become a sudo/root user if you aren’t already, perform these steps:

a)Create a new user, first.
Enter the following command in your terminal after logging in as root:
newuser $ adduser
A password entry prompt will appear. Make sure it is sturdy and enclosed. Additionally, information like your name and phone number will be requested of you. This is unnecessary and optional. To skip, simply use the enter key.

b) Join the sudo group with the user.
Usermod = -aG newuser sudo
There is now a sudo user named newuser.

Step 1: Install OpenJDK

Java Standard Edition (SE) 8 or a later version must be installed in order to instal Tomcat 9. Install OpenJDK, an open-source Java SE and Java Development Kit implementation, to accomplish this (JDK).
You must first upgrade our apt package:
$ sudo apt update
then comes:
$ sudo apt install default-jdk
The most recent version of OpenJDK is OpenJDK14 as of this writing. When the installation is finished, check your Java version as shown below to make sure:
$ java -version

Step 2: Create a Tomcat User

Although Tomcat can be used as the root user, doing so creates a major security risk. In order to begin the service, you must establish a new user with the home directory set to /opt/tomcat. You will instal Tomcat under this directory, which was established with a /bin/false shell so that nobody can log into it.
To achieve this, use the command below:
$ sudo useradd -m -U -d /opt/tomcat -s /bin/false tomcat

Step 3: Install Tomcat

Tomcat’s official download page offers access to the binary distribution.
The Tomcat zip file can be downloaded to a temporary folder location called /tmp using the wget command.
You can choose to download Tomcat using the curl command if you experience problems with wget. Download curl first:
sudo apt instal curl
With the link you obtained from the Tomcat website, use curl next:
$ curl -O https://mirror.kiu.ac.ug/apache/tomcat/tomcat-9/v9.0.45/bin/apache-tomcat-9.0.45.tar.gz

NOTE: You don’t need to use curl if you already used wget. They both succeed in achieving the same objective.
Extraction of the archive into the /opt/tomcat directory occurs after the download is finished:
$ sudo mkdir /opt/tomcat
$ tar -xf apache-tomcat-9.0.45.tar.gz
$ sudo mv apache-tomcat-9.0.45 /opt/tomcat/                                                       Tomcat receives regular upgrades that include patches and security fixes. Make the newest symbolic link point to the installation location so that you have better control over these updates.
$ sudo ln -s latest/opt/tomcat/latest/apache-tomcat-9.0.45
All you will need to do to access an update is unpack your download and change the symbolic link to point to it.
Update permissions next. The user and group for Tomcat are granted permission via the following command:
$ sudo chown -R tomcat: /opt/tomcat
“To grant Tomcat’s bin directory the power to execute shell scripts, you must infuse it with the magic of execution.”
$ sudo sh -c ‘chmod +x /opt/tomcat/latest/bin/*.sh’

Step 4: Create a Unit File

You will need to run Tomcat as a service instead of using shell scripts. This requires a systemd unit file in the /etc/systemd/system/ directory: $ sudo nano /etc/systemd/system/tomcat.service Now paste the configuration below. [Unit] Description=Tomcat 9.0 servlet container After=network.target [Service] Type=forking User=tomcat Group=tomcat Environment=”JAVA_HOME=/usr/lib/jvm/default-java” Environment=”JAVA_OPTS=-Djava.security.egd=file:///dev/urandom” Environment=”CATALINA_BASE=/opt/tomcat/latest” Environment=”CATALINA_HOME=/opt/tomcat/latest” Environment=”CATALINA_PID=/opt/tomcat/latest/temp/tomcat.pid” Environment=”CATALINA_OPTS=-Xms512M -Xmx1024M -server -XX:+UseParallelGC” ExecStart=/opt/tomcat/latest/bin/startup.sh ExecStop=/opt/tomcat/latest/bin/shutdown.sh [Install] WantedBy=multi-user.target

Save and close the file. Then reload systemctl to ensure that the new changes are acknowledged by the system:

$ sudo systemctl daemon-reload

Now start the Tomcat service:

$ sudo systemctl start tomcat

Check if the application has started without any errors:

$ sudo systemctl status tomcat

You can always manage your Tomcat service just like any other systemd service:

$ sudo systemctl start tomcat
$ sudo systemctl stop tomcat
$ sudo systemctl restart tomcat

Step 5: Configure Firewall Settings

Your server might need to be accessed outside of your local network. Change the firewall settings and make port 8080 accessible to accomplish this.
Sudo ufw allow 8080/tcp for $
You can now visit the default Tomcat page by typing your-ip-address:8080 into your web browser after making the necessary changes to the firewall permissions. At this time, avoid clicking the link for your Manager App because you won’t be able to access it (you can configure that later).
Use $ sudo systemctl enable tomcat to have the Tomcat service start automatically when the computer boots up.

Step 6: Configure Management Interface

Because you haven’t yet specified Tomcat users and their roles, you can’t access the web management interface at this time. The descriptor file is tomcat-users.xml. Open it as follows in your terminal:
tomcat-users.xml with sudo nano /opt/tomcat/latest/conf
You will see default content, which includes comments and examples, when the file opens.
Just above /tomcat-users> at the bottom, add the following code.
<role rolename=”admin-gui”/>
<role rolename=”manager-gui”/>

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

</tomcat-users>
The online interface will now be available to the new user (manager-gui and admin-gui). Make sure to replace the password with a more secure one.

Step 7: Test the Installation

Restart your application first:
systemctl restart tomcat with sudo
Enter localhost:8080 in your browser after that. You will be able to tell that the installation was successful when you see the page below.
At http://localhost:8080/manager/html, you can access the Tomcat application manager dashboard. You can manage your applications from this point on by starting, stopping, reloading, deploying, and undeploying them.
It is possible to access the virtual host manager dashboard via http://localhost:8080/host-manager/html. From here, you may control your Tomcat virtual hosts.

 

For reading Similar Article click on this link https://nextepiclife.com/fix-linux-server-issues-with-these-5-troubleshooting-steps/

 

Leave a Reply

Your email address will not be published. Required fields are marked *