install. java Archives - The Linux GURUS https://thelinuxgurus.com/tag/install-java/ Learn Linux & DevOPS from THE LINUX GURUS Mon, 20 Jan 2020 16:01:46 +0000 en-US hourly 1 https://i0.wp.com/thelinuxgurus.com/wp-content/uploads/2020/01/cropped-thelinuxgurus_transparent_name.png?fit=32%2C32&ssl=1 install. java Archives - The Linux GURUS https://thelinuxgurus.com/tag/install-java/ 32 32 148921671 Beginner’s guide to install TOMCAT on UBUNTU https://thelinuxgurus.com/beginners-guide-to-install-tomcat-on-ubuntu/ https://thelinuxgurus.com/beginners-guide-to-install-tomcat-on-ubuntu/#respond Mon, 20 Jan 2020 16:01:46 +0000 https://thelinuxgurus.com/?p=1005 Apache Tomcat is one of the oldest & most widely used open-source web server that is used to serve java-based web-pages, it executes Java servlets...

The post Beginner’s guide to install TOMCAT on UBUNTU appeared first on The Linux GURUS.

]]>
Apache Tomcat is one of the oldest & most widely used open-source web server that is used to serve java-based web-pages, it executes Java servlets and renders Web pages that include Java Server Page coding. It has been used by a number of organizations for serving java web pages. It generally runs JSP, Servlet, etc.

Recommended Read: Beginner’s guide to Backup Postgres Database

Also Read: Introduction to Bash Scripting Tutorial

In this tutorial, we will learn to install Tomcat on Ubuntu Let’s start with the pre-requisites for tomcat installation.

Pre-Requisites

We need to have JAVA installed on the system before we can install tomcat on our systems. To install java 8 on ubuntu, use the following command,

# sudo apt-get install default-jdk

You can refer to this tutorial for detailed instructions on installing java.


Install Tomcat

Let’s first create a home directory for apache tomcat first,

$ mkdir /data/tomcat

Next, to install tomcat on Ubuntu, we will have to download the tar packages for apache tomcat 8. Use the following command to install

$ wget http://mirrors.estointernet.in/apache/tomcat/tomcat-8/v8.5.50/bin/apache-tomcat-8.5.50.tar.gz

Now extract the package to tomcat directory,

$ tar -xvzf apache-tomcat-8.5.50.tar.gz -C /data/tomcat

Our tomcat installation is ready & we can now start tomcat by running the startup script,

$ sh /data/tomcat/bin/startup.sh

But we will create a service script to start & stop tomcat,

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

[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=/data/tomcat/temp/tomcat.pid

Environment=CATALINA_HOME=/data/tomcat

Environment=CATALINA_BASE=/data/tomcat

Environment=’CATALINA_dataS=-Xms512M -Xmx1024M -server -XX:+UseParallelGC’

Environment=’JAVA_dataS=-Djava.awt.headless=true -Djava.security.egd=file:/dev/./urandom’

ExecStart=/data/tomcat/bin/startup.sh

ExecStop=/bin/kill -15 $MAINPID

User=tomcat

Group=tomcat

[Install]

WantedBy=multi-user.target

Now save the file & exit. Load the newly created service into systemd with this command,

# sudo systemctl daemon-reload

We can now start & stop service using the systemctl,

# sudo systemctl start tomcat

You can now check the tomcat installation by opening the following URL on web browser,

http://127.0.0.1:8080

install tomcat on ubuntu

The next, step would be to configure users for the management interface of tomcat.


Configuring Tomcat

Apache tomcat is now ready to be started but before we do that we need to assign credentials to access ‘Manager’ & ‘GUI’ page of tomcat, as by default no user name and pasword is setup. To asisgn the credentials, we will use the ‘/opt/tomcat/conf/tomcat-users.xml ‘ file,

$ sudo vim /opt/tomcat/conf/tomcat-users.xml

& make the following entries to the file,

<role rolename=”manager-gui” />

<user username=”manager” password=”Password@123″ roles=”manager-gui” />

<role rolename=”admin-gui” />

<user username=”admin” password=”Password@123″ roles=”admin-gui” />

Make sure that you make these entries before the tag ‘tomcat-users’, i.e. make above entries before the below mentioned lines,

<tomcat-users xmlns=”http://tomcat.apache.org/xml”

xmlns:xsi=”http://www.w3.org/2001/XMLSchema-instance”

xsi:schemaLocation=”http://tomcat.apache.org/xml tomcat-users.xsd”

version=”1.0″>

Once done, save the file & exit.

We need to make another change, though this is completely optional & completely depends on how you will access the manager page.We can only access the manager page from the browser on localhost but it we to access it on some other remote machines, we need to modify the ‘context.html’ for manager to comment the lines which disables the remote login,

$ sudo vi /opt/tomcat/webapps/manager/META-INF/context.xml

<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>

Same is to be for host-manager’s context file as well,

$ sudo vi /opt/tomcat/webapps/host-manager/META-INF/context.xml

<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>

Now save the file & exit. We can now enter the management interface for tomcat but first we need to restart the apache tomcat,

# sudo systemctl stop tomcat

# sudo systemctl start tomcat

We can now access the management page with the credentials that we have provided above in the configuration. That’s it, we now end this tutorial on how to install Tomcat on Ubuntu Please feel free to send in any questions, queries or suggestions using the comment box below.

If you think we have helped you or just want to support us, please consider these:-

Connect to us: Facebook | Twitter | Linkedin

TheLinuxGURUS are thankful for your continued support.

The post Beginner’s guide to install TOMCAT on UBUNTU appeared first on The Linux GURUS.

]]>
https://thelinuxgurus.com/beginners-guide-to-install-tomcat-on-ubuntu/feed/ 0 1005