0% found this document useful (0 votes)
76 views25 pages

How To Install Apache Tomcat 8 On Ubuntu 16

Download as pdf or txt
Download as pdf or txt
Download as pdf or txt
You are on page 1/ 25

How To Install Apache Tomcat 8 on Ubuntu 16.0... https://www.digitalocean.com/community/tutoria...

Communit Log In ign Up  Menu

B: Justin Ellingwood  ubscribe  hare  Contents 

How To Install Apache Tomcat 8 on


Ubuntu 16.04 21

Posted April 27, 2016  346.2k JAVA APPLICATION UBUNTU UBUNTU 16.04

Introduction
Apache Tomcat is a web server and servlet container that is used to serve Java
applications. Tomcat is an open source implementation of the Java ervlet and
Javaerver Pages technologies, released b the Apache oftware Foundation. This
tutorial covers the basic installation and some configuration of the latest release of
Tomcat 8 on our Ubuntu 16.04 server.

Prerequisites
Before ign
ouup for our newsletter.
begin with thisGet the latest
guide, oututorials
shouldonhave
sAdmin and open
a non-root source
user topics.
with sudo ×
 C R O L Lour
TO TO P
privileges set up on our server. You can learn how to do this b completing
Enter our email address ign Up

1 de 25 9/11/17 09:16
How To Install Apache Tomcat 8 on Ubuntu 16.0... https://www.digitalocean.com/community/tutoria...

Ubuntu 16.04 initial server setup guide.

tep 1: Install Java


Tomcat requires Java to be installed on the server so that an Java web application
code can be executed. We can satisf that requirement b installing OpenJDK with apt-
get.

First, update our apt-get package index:

$ sudo apt-get update

Then install the Java Development Kit package with apt-get:

$ sudo apt-get install default-jdk

Now that Java is installed, we can create a tomcat user, which will be used to run the
Tomcat service.

tep 2: Create Tomcat User


For securit purposes, Tomcat should be run as an unprivileged user (i.e. not root). We
will create a new user and group that will run the Tomcat service.

First, create a new tomcat group:

$ sudo groupadd tomcat

Next, create a new tomcat user. We'll make this user a member of the tomcat group,
with a home director of /opt/tomcat (where we will install Tomcat), and with a shell
of /bin/false (so nobod can log into the account):

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

Sign up for our newsletter. ×


Get the latest tutorials on SysAdmin and open source topics.
Now that our tomcat user is set up, let's download and install Tomcat.S C R O L L TO TOP
ign Up

2 de 25 9/11/17 09:16
How To Install Apache Tomcat 8 on Ubuntu 16.0... https://www.digitalocean.com/community/tutoria...

tep 3: Install Tomcat


The best wa to install Tomcat 8 is to download the latest binar release then configure
it manuall.

Find the latest version of Tomcat 8 at the Tomcat 8 Downloads page. At the time of
writing, the latest version is 8.5.5, but ou should use a later stable version if it is
available. Under the Binar Distributions section, then under the Core list, cop the link
to the "tar.gz".

Next, change to the /tmp director on our server. This is a good director to
download ephemeral items, like the Tomcat tarball, which we won't need after
extracting the Tomcat contents:

$ cd /tmp

Use curl to download the link that ou copied from the Tomcat website:

$ curl -O http://apache.mirrors.ionfish.org/tomcat/tomcat-8/v8.5.5/bin/apache-to

We will install Tomcat to the /opt/tomcat director. Create the director, then extract
the archive to it with these commands:

$ sudo mkdir /opt/tomcat


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

Next, we can set up the proper user permissions for our installation.

tep 4: Update Permissions


The tomcat user that we set up needs to have access to the Tomcat installation. We'll
set that up now.

Change to the director where we unpacked the Tomcat installation:


Sign up for our newsletter. ×
Get the latest tutorials on SysAdmin and open source topics.
SCROLL TO TOP
$ cd /opt/tomcat ign Up

3 de 25 9/11/17 09:16
How To Install Apache Tomcat 8 on Ubuntu 16.0... https://www.digitalocean.com/community/tutoria...

Give the tomcat group ownership over the entire installation director:

$ sudo chgrp -R tomcat /opt/tomcat

Next, give the tomcat group read access to the conf director and all of its contents,
and execute access to the director itself:

$ sudo chmod -R g+r conf


$ sudo chmod g+x conf

Make the tomcat user the owner of the webapps , work , temp , and logs
directories:

$ sudo chown -R tomcat webapps/ work/ temp/ logs/

Now that the proper permissions are set up, we can create a sstemd service file to
manage the Tomcat process.

tep 5: Create a sstemd ervice File


We want to be able to run Tomcat as a service, so we will set up sstemd service file.

Tomcat needs to know where Java is installed. This path is commonl referred to as
"JAVA_HOME". The easiest wa to look up that location is b running this command:

$ sudo update-java-alternatives -l

Output
java-1.8.0-openjdk-amd64 1081 /usr/lib/jvm/java-1.8.0-openjdk-amd64

The correct JAVA_HOME variable can be constructed b taking the output from the last
column (highlighted in red) and appending /jre to the end. Given the example above,
the correct JAVA_HOME for this server would be:
Sign up for our newsletter. ×
Get the latest tutorials on SysAdmin and open source topics.
SCROLL TO TOP
ign Up

4 de 25 9/11/17 09:16
How To Install Apache Tomcat 8 on Ubuntu 16.0... https://www.digitalocean.com/community/tutoria...

JAVA_HOME
/usr/lib/jvm/java-1.8.0-openjdk-amd64/jre

Your JAVA_HOME ma be different.

With this piece of information, we can create the sstemd service file. Open a file called
tomcat.service in the /etc/systemd/system director b tping:

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

Paste the following contents into our service file. Modif the value of JAVA_HOME if
necessar to match the value ou found on our sstem. You ma also want to modif
the memor allocation settings that are specified in CATALINA_OPTS :

/etc/sstemd/sstem/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/./

ExecStart=/opt/tomcat/bin/startup.sh
ExecStop=/opt/tomcat/bin/shutdown.sh

User=tomcat
Group=tomcat
UMask=0007
RestartSec=10
Restart=always
Sign up for our newsletter. ×
Get the latest tutorials on SysAdmin and open source topics.
SCROLL TO TOP
ign Up

5 de 25 9/11/17 09:16
How To Install Apache Tomcat 8 on Ubuntu 16.0... https://www.digitalocean.com/community/tutoria...

[Install]
WantedBy=multi-user.target

When ou are finished, save and close the file.

Next, reload the sstemd daemon so that it knows about our service file:

$ sudo systemctl daemon-reload

tart the Tomcat service b tping:

$ sudo systemctl start tomcat

Double check that it started without errors b tping:

$ sudo systemctl status tomcat

tep 6: Adjust the Firewall and Test the Tomcat


erver
Now that the Tomcat service is started, we can test to make sure the default page is
available.

Before we do that, we need to adjust the firewall to allow our requests to get to the
service. If ou followed the prerequisites, ou will have a ufw firewall enabled
currentl.

Tomcat uses port 8080 to accept conventional requests. Allow traffic to that port b
tping:

$ sudo ufw allow 8080

With the firewall modified, ou can access the default splash page b going to our
Sign up for our newsletter. ×
Get the latest tutorials on SysAdmin and open source topics.
domain or IP address followed b :8080 in a web browser:
SCROLL TO TOP
ign Up

6 de 25 9/11/17 09:16
How To Install Apache Tomcat 8 on Ubuntu 16.0... https://www.digitalocean.com/community/tutoria...

Open in web browser


http://server_domain_or_IP:8080

You will see the default Tomcat splash page, in addition to other information. However,
if ou click the links for the Manager App, for instance, ou will be denied access. We
can configure that access next.

If ou were able to successfull accessed Tomcat, now is a good time to enable the
service file so that Tomcat automaticall starts at boot:

$ sudo systemctl enable tomcat

tep 7: Configure Tomcat Web Management


Interface
In order to use the manager web app that comes with Tomcat, we must add a login to
our Tomcat server. We will do this b editing the tomcat-users.xml file:

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

You will want to add a user who can access the manager-gui and admin-gui (web
apps that come with Tomcat). You can do so b defining a user, similar to the example
below, between the tomcat-users tags. Be sure to change the username and
password to something secure:

tomcat-users.xml — Admin User

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

ave and close the file when ou are finished.

B default, newer versions of Tomcat restrict access to the Manager and Host Manager
Sign up for our newsletter. ×
Get the latest tutorials on SysAdmin and open source topics.
apps to connections coming from the server itself. ince we are installing on a remote
SCROLL TO TOP
machine, ou will probabl want to remove or alter this restriction.
ignTo
Upchange the IP

7 de 25 9/11/17 09:16
How To Install Apache Tomcat 8 on Ubuntu 16.0... https://www.digitalocean.com/community/tutoria...

address restrictions on these, open the appropriate context.xml files.

For the Manager app, tpe:

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

For the Host Manager app, tpe:

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

Inside, comment out the IP address restriction to allow connections from anwhere.
Alternativel, if ou would like to allow access onl to connections coming from our
own IP address, ou can add our public IP address to the list:

context.xml files for Tomcat webapps

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

ave and close the files when ou are finished.

To put our changes into effect, restart the Tomcat service:

$ sudo systemctl restart tomcat

tep 8: Access the Web Interface


Now that we have create a user, we can access the web management interface again
in a web browser. Once again, ou can get to the correct interface b entering our
server's domain name or IP address followed on port 8080 in our browser:

Open in web browser


Sign up for our newsletter.
Get the latest tutorials on SysAdmin and open source topics.
http://server_domain_or_IP:8080 ×
SCROLL TO TOP
ign Up

8 de 25 9/11/17 09:16
How To Install Apache Tomcat 8 on Ubuntu 16.0... https://www.digitalocean.com/community/tutoria...

The page ou see should be the same one ou were given when ou tested earlier:

Let's take a look at the Manager App, accessible via the link or
http://server_domain_or_IP:8080/manager/html . You will need to enter the
account credentials that ou added to the tomcat-users.xml file. Afterwards, ou
should see a page that looks like this:

Sign up for our newsletter. ×


Get the latest tutorials on SysAdmin and open source topics.
SCROLL TO TOP
The Web Application Manager is used to manage our Java applications.
ign Up You can tart,

9 de 25 9/11/17 09:16
How To Install Apache Tomcat 8 on Ubuntu 16.0... https://www.digitalocean.com/community/tutoria...

top, Reload, Deplo, and Undeplo here. You can also run some diagnostics on our
apps (i.e. find memor leaks). Lastl, information about our server is available at the
ver bottom of this page.

Now let's take a look at the Host Manager, accessible via the link or
http://server_domain_or_IP:8080/host-manager/html/ :

From the Virtual Host Manager page, ou can add virtual hosts to serve our
applications from.

Conclusion
Your installation of Tomcat is complete! Your are now free to deplo our own Java web
applications!

Currentl, our Tomcat installation is functional, but entirel unencrpted. This means
that all data, including sensitive items like passwords, are sent in plain text that can be
intercepted and read b other parties on the internet. In order to prevent this from
happening, it is strongl recommended that ou encrpt our connections with L.
You can find out how to encrpt our connections to Tomcat b following this guide.

Sign up for our newsletter.


Get the latest tutorials on SysAdmin and open source topics.×
B: Justin Ellingwood Upvote (21)  ubscribe
ign Up
SCROLL 
T O Thare
OP

10 de 25 9/11/17 09:16
How To Install Apache Tomcat 8 on Ubuntu 16.0... https://www.digitalocean.com/community/tutoria...

Introducing paces: Object torage on DigitalOcean


A simple and cost-effective wa to store, serve, backup, and archive a virtuall
infinite amount of media, content, images, and static files for our apps.

Related Tutorials
How to et Up hin erver on Ubuntu 16.04

How To Install and Use Webmin on CentO 7

How to Install Perlbrew and Manage Multiple Versions of Perl 5 on CentO 7

How To Build Go Executables for Multiple Platforms on Ubuntu 16.04

How To Install Webmin on Ubuntu 16.04

67 Comments

Sign up for our newsletter. ×


Get the latest tutorials on SysAdmin and open source topics.
SCROLL TO TOP
ign Up

11 de 25 9/11/17 09:16
How To Install Apache Tomcat 8 on Ubuntu 16.0... https://www.digitalocean.com/community/tutoria...

Leave a comment...

Log In to Comment

Trex June 14, 2016

0 To ensure the Tomcat service re-starting at boot, ou have to enable it:

$ sudo sstemctl enable tomcat

P4d4B0u June 20, 2016

1 Hello,

For me (in ubuntu 14 (i know this is for ubuntu 16)), in the step 4 :
sudo chmod g+r conf/* ==> does not work "No file or director".

Is it normal ?

Thanks for the step b step tomcat installation procedure.

FernandoCarv June 26, 2016

0 Before the step 4 when using curl -0 " archive_URL " is indicated

You will need to modif:

curl -O http://apache.mirrors.ionfish.org/tomcat/tomcat-8/v8.0.36/bin/a

Then see if ou can move to the other steps .


Sign up for our newsletter.
I have helped .
Get the latest tutorials on SysAdmin and open source topics.×
SCROLL TO TOP
ign Up

12 de 25 9/11/17 09:16
How To Install Apache Tomcat 8 on Ubuntu 16.0... https://www.digitalocean.com/community/tutoria...

adminbbd0b80780 August 15, 2016

0 I get the same on Ubuntu 16...

adminbbd0b80780 August 15, 2016

0 Actuall if ou are using the extra sudo user from digital ocean's first setup guide
("demo"), then check if that user is part of the "tomcat" group. If ou add them to
the tomcat group, then it should work. I'm not sure if this is an oversight in the
article.

acoram Septemer 30, 2016

0 i have 16.04.1 and it happends to me too.

ssadmin@vm-tomcat:/opt$ sudo chmod g+r conf/*


chmod: cannot access 'conf/*': No such file or director

it doesn't make sense.

jellingwood MOD Octoer 3, 2016

0 @P4d4B0u @FernandoCarv @adminbbd0b80780 @acoram Hello, sorr for the


delaed response.

It looks like there were some changes to the wa that the Tomcat files were
being packaged b Apache that caused some of the commands to fail in more
recent installations. I've updated the guide to assign different permissions and
ownership in line with the suggestions here, and also made a few adjustments
to account for some other packaging changes (IP address restrictions). orr
for the inconvenience. Hopefull this will fix some of these issues.

Madd June 27, 2016

1 I get error in the step when we start the tomcat service


sudo systemctl start tomcat
On checking the status b this command - sudo systemctl status tomcat . I
Sign up for our newsletter.
see following error -
Get the latest tutorials on SysAdmin and open source topics. ×
SCROLL TO TOP
Jun 27 16:09:52 madd-VirtualBox sstemd[6182]: tomcat.service: Failed at step EXEC
ign Up

13 de 25 9/11/17 09:16
How To Install Apache Tomcat 8 on Ubuntu 16.0... https://www.digitalocean.com/community/tutoria...

spawning /opt/tomcat/bin/startup.sh: Permission denied

Although I am logged in as user (which has sudo privileges) still I am getting Permission
denied error. I have also changed the ownership of /opt/tomcat/bin director to the
user from which I am firing those commands, still the error is coming.

Can anbod help me in this problem?

adminbbd0b80780 August 15, 2016

0 Did ou ever figure this out?

codsp July 6, 2016

0 Hello,
I've got this error and can not shutdown the tomcat properl.
Is there a wa to solve it?

Using CATALINA_BASE: /opt/tomcat


Using CATALINA_HOME: /opt/tomcat
Using CATALINA_TMPDIR: /opt/tomcat/temp
Using JRE_HOME: /usr/lib/jvm/java-8-oracle/jre
Using CLASSPATH: /opt/tomcat/bin/bootstrap.jar:/opt/tomcat/bin/tomca
Jul 06, 2016 5:54:58 PM org.apache.catalina.startup.Catalina stopServer
SEVERE: Could not contact localhost:8005. Tomcat may not be running.
Jul 06, 2016 5:54:58 PM org.apache.catalina.startup.Catalina stopServer
SEVERE: Catalina.stop:
java.net.ConnectException: Connection refused
at java.net.PlainSocketImpl.socketConnect(Native Method)
at java.net.AbstractPlainSocketImpl.doConnect(AbstractPlainSocketImpl.
at java.net.AbstractPlainSocketImpl.connectToAddress(AbstractPlainSock
at java.net.AbstractPlainSocketImpl.connect(AbstractPlainSocketImpl.ja
at java.net.SocksSocketImpl.connect(SocksSocketImpl.java:392)
at java.net.Socket.connect(Socket.java:589)
at java.net.Socket.connect(Socket.java:538)
at java.net.Socket.<init>(Socket.java:434)
at java.net.Socket.<init>(Socket.java:211)
at org.apache.catalina.startup.Catalina.stopServer(Catalina.java:476)
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
Sign up for our newsletter.
Get the latest tutorials on SysAdmin and open source topics.
at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImp ×
SCROLL TO TOP
ign Up

14 de 25 9/11/17 09:16
How To Install Apache Tomcat 8 on Ubuntu 16.0... https://www.digitalocean.com/community/tutoria...

at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccesso
at java.lang.reflect.Method.invoke(Method.java:498)
at org.apache.catalina.startup.Bootstrap.stopServer(Bootstrap.java:408)
at org.apache.catalina.startup.Bootstrap.main(Bootstrap.java:497)

Thank ou.

uncleboni July 30, 2016

5 If ou are having problems getting tomcat 8 to start and getting this error

● tomcat.service - Apache Tomcat Web Application Container Loaded: loaded


(/etc/sstemd/sstem/tomcat.service; enabled; vendor preset: enabled) Active:
activating (auto-restart) (Result: exit-code) since at 2016-07-30 12:15:27 EDT; 1s ago
Process: 13807 Exectart=/opt/tomcat/bin/startup.sh (code=exited, status=203/EXEC)
Jul 30 12:15:27 xxxxxxx sstemd[1]: Failed to start Apache Tomcat Web Application
Container. Jul 30 12:15:27 xxxxxxx sstemd[1]: tomcat.service: Unit entered failed state.
Jul 30 12:15:27 xxxxxxxxx sstemd[1]: tomcat.service: Failed with result 'exit-code'.

then ou might want to give tomcat user ownership of the whole tomcat director:

cd /opt && sudo chown -R tomcat tomcat/

Worked for me.

ee http://unix.stackexchange.com/questions/235891/tomcat-8-will-not-start-after-
initial-install

ibr33 August 7, 2016

0 Thank ou uncleboni

adminbbd0b80780 August 15, 2016

0 I have the same problem - is it safe to make the tomcat user the owner of the
whole /tomcat folder?

Sign up for our newsletter.


Get the latest tutorials on SysAdmin and open source topics. ×
SCROLL TO TOP
ign Up
sonamhava August 17, 2016

15 de 25 9/11/17 09:16
How To Install Apache Tomcat 8 on Ubuntu 16.0... https://www.digitalocean.com/community/tutoria...

Thanks for posting this.

esteban76 Septemer 3, 2016

0 Thanks a lot!!!

jellingwood MOD Octoer 3, 2016

0 As mentioned in another comment, it looks like there were some changes to


the wa that the Tomcat files were being packaged b Apache that caused
some of the commands to fail in more recent installations. I apologize that the
instructions were not working for awhile.

I've updated the guide to assign different permissions and ownership in line
with the suggestions here, and also made a few adjustments to account for
some other packaging changes (IP address restrictions). orr for the
inconvenience. Hopefull this will fix some of these issues.

acronim August 20, 2016

0 Hi

Just installed Tomcat 8on Ubuntu 16.04 . Changed the Tomcat-user.xml file too with
manager-gui role and changed the password , but I keep getting the 403 Access
Denied Page when I click the Manager App from the Tomcat 8

Is there some permissions I have not set ?

Thanks

jellingwood MOD Octoer 3, 2016

0 @acronim: As mentioned in another comment, it looks like there were some


changes to the wa that the Tomcat files were being packaged b Apache that
caused some of the commands to fail in more recent installations. I apologize that
the instructions were not working for awhile.

I've updated the guide to assign different permissions and ownership in line with
the suggestions here, and also made a few adjustments to account for some other
Sign up for our newsletter.
Get the latest tutorials on SysAdmin and open source topics. ×
packaging changes (IP address restrictions). orr for the inconvenience. Hopefull
SCROLL TO TOP
this will fix some of these issues. ign Up

16 de 25 9/11/17 09:16
How To Install Apache Tomcat 8 on Ubuntu 16.0... https://www.digitalocean.com/community/tutoria...

The specific changes ou'll want to look into are the ones dealing with the
context.xml files.

kailashrao August 22, 2016

0 Hi, i have been tring to figure this out for a week but unable to get Tomcat 8 to start
while following this guide.

--
-- Unit tomcat.service has failed.
--
-- The result is failed.
Aug 22 00:12:17 aimed-ubuntu-blr systemd[1]: tomcat.service: Unit entered
Aug 22 00:12:17 aimed-ubuntu-blr systemd[1]: tomcat.service: Failed with r
Aug 22 00:12:27 aimed-ubuntu-blr systemd[1]: tomcat.service: Service hold-
Aug 22 00:12:27 aimed-ubuntu-blr systemd[1]: Stopped Apache Tomcat Web App
-- Subject: Unit tomcat.service has finished shutting down
-- Defined-By: systemd
-- Support: http://lists.freedesktop.org/mailman/listinfo/systemd-devel
--
-- Unit tomcat.service has finished shutting down.
Aug 22 00:12:27 aimed-ubuntu-blr systemd[1]: Starting Apache Tomcat Web Ap
-- Subject: Unit tomcat.service has begun start-up
-- Defined-By: systemd
-- Support: http://lists.freedesktop.org/mailman/listinfo/systemd-devel
--
-- Unit tomcat.service has begun starting up.
Aug 22 00:12:27 aimed-ubuntu-blr systemd[26177]: tomcat.service: Failed at
-- Subject: Process /opt/tomcat/bin/startup.sh could not be executed
-- Defined-By: systemd
-- Support: http://lists.freedesktop.org/mailman/listinfo/systemd-devel
--
-- The process /opt/tomcat/bin/startup.sh could not be executed and failed
--
-- The error number returned by this process is 13.
Aug 22 00:12:27 aimed-ubuntu-blr systemd[1]: tomcat.service: Control proce
Aug 22 00:12:27 aimed-ubuntu-blr systemd[1]: Failed to start Apache Tomcat
-- Subject: Unit tomcat.service has failed
-- Defined-By: systemd
Sign up for our newsletter.
Get the latest tutorials on SysAdmin and open source topics.
-- Support: http://lists.freedesktop.org/mailman/listinfo/systemd-devel ×
SCROLL TO TOP
-- ign Up

17 de 25 9/11/17 09:16
How To Install Apache Tomcat 8 on Ubuntu 16.0... https://www.digitalocean.com/community/tutoria...

-- Unit tomcat.service has failed.


--
-- The result is failed.
Aug 22 00:12:27 aimed-ubuntu-blr systemd[1]: tomcat.service: Unit entered fail
Aug 22 00:12:27 aimed-ubuntu-blr systemd[1]: tomcat.service: Failed with resul

ounisabed Septemer 3, 2016

0 Had the same problem! followed @uncleboni 's advice and gave ownership of
/opt/tomcat to 'tomcat' user. The problem is gone now!
At least it starts now, but what about securit?

Have to tweak the sstem a bit further I guess!

jellingwood MOD Octoer 3, 2016

0 @kailashrao @ounisabed First of all, I apologize for the delaed response.

As mentioned in another comment, it looks like there were some changes to


the wa that the Tomcat files were being packaged b Apache that caused
some of the commands to fail in more recent installations. I apologize that the
instructions were not working for awhile.

I've updated the guide to assign different permissions and ownership in line
with the suggestions here, and also made a few adjustments to account for
some other packaging changes (IP address restrictions). orr for the
inconvenience. Hopefull this will fix some of these issues.

riahc4 Septemer 6, 2016

0 Im having a issue that when I restarted the Ubuntu 16.04 running Tomcat 8, it would
not let me access...

I saw that it was binding it to IPv6 so I disabled it a kernel level. Now it is listening to
IPv4 but it still does not let me access.

Sign up for our newsletter.


Get the latest tutorials on SysAdmin and open source topics.
spadinha Septemer 13, 2016
×
SCROLL TO TOP
ign Up
0 Hello, I having a problem on this step.

18 de 25 9/11/17 09:16
How To Install Apache Tomcat 8 on Ubuntu 16.0... https://www.digitalocean.com/community/tutoria...

root@Bab-Concept:/tmp# sudo sstemctl start tomcat


Job for tomcat.service failed because the control process exited with error code. ee
"sstemctl status tomcat.service" and "journalctl -xe" for details.

root@Bab-Concept:/tmp# sstemctl status tomcat.service


● tomcat.service - Apache Tomcat Web Application Container
Loaded: loaded (/etc/sstemd/sstem/tomcat.service; enabled; vendor preset: e
Active: activating (auto-restart) (Result: exit-code) since Tue 2016-09-13 17
Process: 2870 Exectart=/opt/tomcat/bin/startup.sh (code=exited, status=203/EX

-- Defined-B: sstemd

-- upport: http://lists.freedesktop.org/mailman/listinfo/sstemd-devel
-- Unit tomcat.service has begun starting up.
ep 13 17:39:33 Bab-Concept sstemd[2887]: tomcat.service: Failed at step EXEC
-- ubject: Process /opt/tomcat/bin/startup.sh could not be executed
-- Defined-B: sstemd

-- upport: http://lists.freedesktop.org/mailman/listinfo/sstemd-devel -- The process


/opt/tomcat/bin/startup.sh could not be executed and failed.
-- The error number returned b this process is 13.
ep 13 17:39:33 Bab-Concept sstemd[1]: tomcat.service: Control process exited,
ep 13 17:39:33 Bab-Concept sstemd[1]: Failed to start Apache Tomcat Web Appli
-- ubject: Unit tomcat.service has failed
-- Defined-B: sstemd

-- upport: http://lists.freedesktop.org/mailman/listinfo/sstemd-devel -- Unit


tomcat.service has failed.
-- The result is failed.
ep 13 17:39:33 Bab-Concept sstemd[1]: tomcat.service: Unit entered failed sta
ep 13 17:39:33 Bab-Concept sstemd[1]: tomcat.service: Failed with result 'exi
lines 3191-3213/3213 (END)

raghubatta007 Octoer 1, 2016

0 Hello There, I too encountered 2 errors.

1. sudo chmod g+r conf/*


said that No such file or director
o i changed the path to /opt/tomcat using command sudo chmod g+r conf
/opt/tomcat
Sign upand no error
for our occured.
newsletter.
Get the latest tutorials on SysAdmin and open source topics. ×
SCROLL TO TOP
2. But while tarting the Tomcat service using command sudo sstemctl start
ign Up

19 de 25 9/11/17 09:16
How To Install Apache Tomcat 8 on Ubuntu 16.0... https://www.digitalocean.com/community/tutoria...

tomcat it responded that Job for tomcat.service failed because the control process
exited with error code. ee "sstemctl status tomcat.service" and "journalctl -xe" for
details.

mobi@mobi-near:/tmp$ cd /opt/tomcat
mobi@mobi-near:/opt/tomcat$ sudo chgrp -R tomcat conf
mobi@mobi-near:/opt/tomcat$ sudo chmod g+rwx conf
mobi@mobi-near:/opt/tomcat$ sudo chmod g+r conf/*
chmod: cannot access 'conf/*': No such file or directory
mobi@mobi-near:/opt/tomcat$ sudo chmod g+r conf/opt/tomcat
chmod: cannot access 'conf/opt/tomcat': No such file or directory
mobi@mobi-near:/opt/tomcat$ sudo chmod g+r conf /opt/tomcat
mobi@mobi-near:/opt/tomcat$ sudo chown -R tomcat webapps/ work/ temp/ logs/
mobi@mobi-near:/opt/tomcat$ sudo update-java-alternatives -l
java-8-oracle 1 /usr/lib/jvm/java-8-oracle
mobi@mobi-near:/opt/tomcat$ ^C
mobi@mobi-near:/opt/tomcat$ /usr/lib/jvm/java-8-oracle/jre
bash: /usr/lib/jvm/java-8-oracle/jre: Is a directory
mobi@mobi-near:/opt/tomcat$ sudo nano /etc/systemd/system/tomcat.service
Use "fg" to return to nano.

[1]+ Stopped sudo nano /etc/systemd/system/tomcat.service


mobi@mobi-near:/opt/tomcat$ fg
sudo nano /etc/systemd/system/tomcat.service
mobi@mobi-near:/opt/tomcat$ sudo systemctl daemon-reload
mobi@mobi-near:/opt/tomcat$ sudo systemctl start tomcat
Job for tomcat.service failed because the control process exited with error co
mobi@mobi-near:/opt/tomcat$ sudo systemctl start tomcat
Job for tomcat.service failed because the control process exited with error co
mobi@mobi-near:/opt/tomcat$ systemctl status tomcat.service
● tomcat.service - Apache Tomcat Web Application Container
Loaded: loaded (/etc/systemd/system/tomcat.service; disabled; vendor preset
Active: activating (auto-restart) (Result: exit-code) since Sat 2016-10-01
Process: 6529 ExecStart=/opt/tomcat/bin/startup.sh (code=exited, status=203/

Oct 01 13:53:33 mobi-near systemd[1]: tomcat.service: Control process exited,


Oct 01 13:53:33 mobi-near systemd[1]: Failed to start Apache Tomcat Web Applic
Oct 01 13:53:33 mobi-near systemd[1]: tomcat.service: Unit entered failed stat
Oct 01 13:53:33 mobi-near systemd[1]: tomcat.service: Failed with result 'exit
Sign up for our newsletter.
Get the latest tutorials on SysAdmin and open source topics. ×
SCROLL TO TOP
mobi@mobi-near:/opt/tomcat$ sudo systemctl status tomcat
ign Up

20 de 25 9/11/17 09:16
How To Install Apache Tomcat 8 on Ubuntu 16.0... https://www.digitalocean.com/community/tutoria...

[sudo] password for mobi:

I want to know what was the mistake done b me . Is problem no.2 arrised due to wrong path
mentioned in 1 ).

the file tomcat.service was not present in the director mentioned so I opened it using
Terminal & made changes in the terminal

jellingwood MOD Octoer 3, 2016

1 @raghubatta007 He there. I've just had a chance to go through the guide again
and check this out. It looks like there were some changes to the wa that the
Tomcat files were being packaged b Apache that caused some of the commands
to fail in more recent installations. I apologize that the instructions were not
working for awhile.

I've updated the guide to assign different permissions and ownership in line with
the suggestions here, and also made a few adjustments to account for some other
packaging changes (IP address restrictions). orr for the inconvenience. Hopefull
this will fix some of these issues.

raghubatta007 Octoer 4, 2016

0 Hello there,
Thanks for giving our precious time for Repling so quickl . I have
successfull Installed & configured Apache Tomcat .
Can ou please tell me how can I install Oracle 10g database in Ubuntu 16.04 .
even its now not supported b Oracle.:)

Thanks

lstenning Octoer 5, 2016

1 I have followed these instructions to a T, and have also read through all comments and
a couple stackexchange 'fixes.'
m sstemd file works fine, tomcat starts and is accessible at m droplets ip:8080.
BUT, when I check sudo sstemctl status tomcat, i get the following:
Sign up for our newsletter.
Get the latest tutorials on SysAdmin and open source topics. ×
SCROLL TO TOP
● tomcat.service - Apache Tomcat Web Application
ign UpContainer

21 de 25 9/11/17 09:16
How To Install Apache Tomcat 8 on Ubuntu 16.0... https://www.digitalocean.com/community/tutoria...

Loaded: loaded (/etc/systemd/system/tomcat.service; enabled; vendor preset:


Active: activating (auto-restart) (Result: exit-code) since Wed 2016-10-05
**Process: 23323 ExecStop=/opt/tomcat/bin/shutdown.sh (code=exited, status=1
Process: 23308 ExecStart=/opt/tomcat/bin/startup.sh (code=exited, status=0/S
Main PID: 23320 (code=exited, status=1/FAILURE)

Oct 05 15:34:36 sys-name systemd[1]: tomcat.service: Control process exited, c


Oct 05 15:34:36 sys-name systemd[1]: tomcat.service: Unit entered failed state
**Oct 05 15:34:36 sys-name systemd[1]: tomcat.service: Failed with result 'exi

This causes tomcat to stop. After rebooting the server everthing works again.
I've fixed permissions on shutdown.sh and all files in bin using:

chgrp -R tomcat bin


chmod g+rwx bin
chmod g+r bin/*

An ideas whats wrong here?

nizamalsiddiq96 Octoer 13, 2016

0 he gus anbod can help me out with this? im new to linux so kinda lost and stuff
i keep getting chown: invalid user: ‘tomcat’ when i do the step 4
sudo chown -R tomcat webapps/ work/ temp/ logs/

pifou42 Octoer 13, 2016

0 [deleted]

pifou42 Octoer 13, 2016

0 Are ou sure ou created our user correctl ? ou can check that it exists, e.g. b
running "sudo cat /etc/passwd" (the last output line should be something like
"tomcat:x:1001:1001::/opt/tomcat:/bin/false")

Sign up for our newsletter.


Get the latest tutorials on SysAdmin and open source topics. ×
pifou42 Octoer 13, 2016 SCROLL TO TOP
ign Up

22 de 25 9/11/17 09:16
How To Install Apache Tomcat 8 on Ubuntu 16.0... https://www.digitalocean.com/community/tutoria...

Great tutorial. Explainations are short but clear and concise. Huge thanks gus !

miracatici Octoer 18, 2016

3 I've lost 1 hour with following error : Exectop=/opt/tomcat/bin/shutdown.sh


(code=exited, status=1/FAILURE)

OLUTION : We have to edit CATALINA_OPT memor parameters in the


tomcat.service file according to our droplet ram size. I use basic droplet. When I
changed the values to -Xms128M -Xmx512M everthing works fine.

jammgit June 18, 2017

0 thanks for posting this!

matthewmccollom Octoer 30, 2016

0 If anone is tring to write files and getting permission denied errors, this is what I did
to fix:

Add the following to /etc/sstemd/sstem/tomcat.service. It sets the working director


of the java process to /opt/tomcat/work.

WorkingDirectory=/opt/tomcat/work

garretwilson Novemer 9, 2016

0 I'm comparing this tomcat.service file to that listed for Centos 7 at


https://www.digitalocean.com/communit/tutorials/how-to-install-apache-tomcat-8-on-
centos-7 . I'm tring to get a consistent install across platforms, plus I'm wanting to full
understand the best options. Could someone explain the differences between these
two files (other than the JAVA_HOME, obviousl)?

For example, this file has the following not found in the CentO 7 example:
Group=tomcat
UMask=0007
Sign up for our newsletter.
Restartec=10
Get the latest tutorials on SysAdmin and open source topics. ×
SCROLL TO TOP
Restart=alwas ign Up

23 de 25 9/11/17 09:16
How To Install Apache Tomcat 8 on Ubuntu 16.0... https://www.digitalocean.com/community/tutoria...

Plus the reference to sslog.target is missing.

Are these differences unique to Ubuntu, or should the be in the CentO 7 version as well?
Wh are the needed?

How To Install Apache Tomcat 8 on CentO 7

Apache Tomcat is a web server and servlet


container that is used to serve Java
applications. Tomcat is an open source

gupaddock Novemer 12, 2016

0 Out of curiosit, wh is this preferred over sudo apt-get install tomcat8 ?

bogdanvlviv Decemer 3, 2016

0 tep 2: Create Tomcat User sudo adduser --system --group --no-create-


home tomcat

Load More Comments

This work is licensed under a Creative


Commons Attribution-NonCommercial-
hareAlike 4.0 International License.

Sign up for our newsletter. ×


Get the latest tutorials on SysAdmin and open source topics.
SCROLL TO TOP
ign Up

24 de 25 9/11/17 09:16
How To Install Apache Tomcat 8 on Ubuntu 16.0... https://www.digitalocean.com/community/tutoria...


Copright © 2017 DigitalOcean™ Inc.

Communit Tutorials Questions Projects Tags Newsletter R 

Distros & One-Click Apps Terms, Privac, & Copright ecurit Report a Bug
Write for DigitalOcean hop

Sign up for our newsletter. ×


Get the latest tutorials on SysAdmin and open source topics.
SCROLL TO TOP
ign Up

25 de 25 9/11/17 09:16

You might also like