how to install apache tomcat on ubuntu 12

15
11/1/13 How To Install Apache Tomcat on Ubuntu 12.04 | DigitalOcean https://www.digitalocean.com/community/articles/how-to-install-apache-tomcat-on-ubuntu-12-04 1/15 Pricing Features Customers Help & Community Sign Up Login Help & Community Articles & Tutorials Questions Chat Blog Try this tutorial on an SSD cloud server. Your email Create a password Get Started! Includes 512MB RAM, 20GB SSD Disk, and 1TB Transfer for $5/mo! Learn more . Related Articles Ubuntu How To Create a SSL Certificate on Apache for Ubuntu 12.04 How To Install Git on Ubuntu 12.04 How To Set Up Apache Virtual Hosts on Ubuntu 12.04 LTS How To Install Linux, Apache, MySQL, PHP (LAMP) stack on Ubuntu How To Install Ruby on Rails on Ubuntu 12.04 LTS (Precise Pangolin) with RVM Apache How To Create a SSL Certificate on Apache for Ubuntu 12.04 How To Install Linux, Apache, MySQL, PHP (LAMP) stack On CentOS 6 How To Install Linux, Apache, MySQL, PHP (LAMP) stack On CentOS 6 How To Set Up Apache Virtual Hosts on Ubuntu 12.04 LTS How To Install Linux, Apache, MySQL, PHP (LAMP) stack on Ubuntu Miscellaneous How To Install and Use Memcache on Ubuntu 12.04 How To Launch Your Site on a New Ubuntu 12.04 Server with LAMP, SFTP, and DNS How To Set Up a Minecraft Server on Linux How To Install Apache Tomcat on Ubuntu 12.04 How To Install Git on Ubuntu 12.04 How To Install Apache Tomcat on Ubuntu 12.04

Upload: sahad-sali

Post on 26-Oct-2015

265 views

Category:

Documents


0 download

TRANSCRIPT

Page 1: How to Install Apache Tomcat on Ubuntu 12

11/1/13 How To Install Apache Tomcat on Ubuntu 12.04 | DigitalOcean

https://www.digitalocean.com/community/articles/how-to-install-apache-tomcat-on-ubuntu-12-04 1/15

Pricing

FeaturesCustomers

Help & Community

Sign Up LoginHelp & Community

Articles & Tutorials

Questions

ChatBlog

Try this tutorial on an SSD cloud server.

Your email Create a password Get Started!

Includes 512MB RAM, 20GB SSD Disk, and 1TB Transfer for $5/mo! Learn more.

Related Articles

Ubuntu

How To Create a SSL Certificate on Apache for Ubuntu 12.04

How To Install Git on Ubuntu 12.04How To Set Up Apache Virtual Hosts on Ubuntu 12.04 LTSHow To Install Linux, Apache, MySQL, PHP (LAMP) stack on UbuntuHow To Install Ruby on Rails on Ubuntu 12.04 LTS (Precise Pangolin) with RVM

Apache

How To Create a SSL Certificate on Apache for Ubuntu 12.04How To Install Linux, Apache, MySQL, PHP (LAMP) stack On CentOS 6

How To Install Linux, Apache, MySQL, PHP (LAMP) stack On CentOS 6

How To Set Up Apache Virtual Hosts on Ubuntu 12.04 LTSHow To Install Linux, Apache, MySQL, PHP (LAMP) stack on Ubuntu

Miscellaneous

How To Install and Use Memcache on Ubuntu 12.04

How To Launch Your Site on a New Ubuntu 12.04 Server with LAMP, SFTP, and DNSHow To Set Up a Minecraft Server on Linux

How To Install Apache Tomcat on Ubuntu 12.04

How To Install Git on Ubuntu 12.04

How To Install Apache Tomcat on Ubuntu 12.04

Page 2: How to Install Apache Tomcat on Ubuntu 12

11/1/13 How To Install Apache Tomcat on Ubuntu 12.04 | DigitalOcean

https://www.digitalocean.com/community/articles/how-to-install-apache-tomcat-on-ubuntu-12-04 2/15

Tweet 8 8

submit

Write an Article

About Apache Tomcat

Apache tomcat is a Java based application server released by the Apache Software Foundation. It is a web server and a servletcontainer for Java web applications.

Setup

Tomcat installation on a virtual private server is relatively easy. Its single required dependency is Java and this tutorial will include a

step on how to install that platform.

You do need to have a user with sudo privileges for this tutorial.

Step One—Install Tomcat

The most recent version of Tomcat is 7, and it can be easily downloaded through apt-get or from the Apache Tomcat site.

You can download it through apt-get by typing:

sudo apt-get install tomcat7

To download tomcat from their site, copy the link for the tar.gz package under the “Core” section and begin the download. You

will get a link that originates from one of Apache’s many mirrors, making the command look mostly like this (although coming from

a different site).

wget http://mirror.atlanticmetro.net/apache/tomcat/tomcat-7/v7.0.29/bin/apache-tomcat-7.0.29.tar.gz

After the download completes, untar the file.

tar xvzf apache-tomcat-7.0.29.tar.gz

Finish up the Tomcat installation on the VPS by moving the files to a convenient directory.

sudo mv apache-tomcat-7.0.29 ~/path/to/tomcat

Step Two—Install Java

We installed the entire Apache Tomcat server on our virtual server in the previous step. Before we can use it, however, we do

need to have Java installed on the VPS as well. If you currently do not have java, you can download it quite easily with apt-get.

sudo apt-get install default-jdk

Once you have Tomcat and Java installed on the virtual private server, all that remains is to start them.

17Like

Share 1

Page 3: How to Install Apache Tomcat on Ubuntu 12

11/1/13 How To Install Apache Tomcat on Ubuntu 12.04 | DigitalOcean

https://www.digitalocean.com/community/articles/how-to-install-apache-tomcat-on-ubuntu-12-04 3/15

Step Three—Configure .bashrc

In order to start Tomcat, we need to add it as an environment variable in the /.bashrc file.

sudo nano ~/.bashrc

You can add this information to the end of the file:

export JAVA_HOME=/usr/lib/jvm/default-java

export CATALINA_HOME=~/path/to/tomcat

Save and exit out of .bashrc. You can make the changes effective by restarting the bashrc file.

. ~/.bashrc

Step Four—RESULTS

Tomcat is now installed and configured on our virtual servers. However, it is not yet activated. The final step is to activate Tomcatby running its startup script:

$CATALINA_HOME/bin/startup.sh

Once that runs, Tomcat is up and ready on port 8080.

You can visually verify that Tomcat is working by accessing your server page at your_IP_address:8080.

It should look like this

By Etel Sverdlov

Try this tutorial on an SSD cloud server.

Your email Create a password Get Started!

Includes 512MB RAM, 20GB SSD Disk, and 1TB Transfer for $5/mo! Learn more.

Comments

maiconfz

Thanks!!! IT WORKS!!!

Obs.: You can access the server at [droplet-ip]:8080/ .It's not at localhost:8080/

Posted November 13th, 2012 20:45

Page 4: How to Install Apache Tomcat on Ubuntu 12

11/1/13 How To Install Apache Tomcat on Ubuntu 12.04 | DigitalOcean

https://www.digitalocean.com/community/articles/how-to-install-apache-tomcat-on-ubuntu-12-04 4/15

Etel

You're totally right! I corrected it above. Thank you!

Posted November 13th, 2012 20:47

kasongoyo

what is droplet-ip? i couldnt run the server

Posted November 20th, 2012 05:27

Etel

Droplet IP refers to your server's IP address. DigitalOcean servers are called Droplets.

Posted November 28th, 2012 19:03

a2165653

what is ~/path/to/tomcat ?

can you explain more?

Thanks!

Posted December 11th, 2012 14:16

Etel

This is the extension to where you place your tomcat file. It is different depending on where you choose to install it.

Posted December 11th, 2012 14:40

Page 5: How to Install Apache Tomcat on Ubuntu 12

11/1/13 How To Install Apache Tomcat on Ubuntu 12.04 | DigitalOcean

https://www.digitalocean.com/community/articles/how-to-install-apache-tomcat-on-ubuntu-12-04 5/15

Server

Thank you for the notes. Could you explain why this tutorial did not just use apt-get to install the tomcat7 package? Also, how can

we setup tomcat to auto start on server reboot?

Thanks!

Posted January 21st, 2013 01:12

John Lussmyer

I used the "sudo apt-get install tomcat7", and it installed tomcat to /usr/share/tomcat7

It also installed the openjdk version of Java.

I did have to edit the .bashrc to add the 2 settings. I also needed to set CATALINA_OUT=/var/log/tomcat7/catalina.out

The problem is that tomcat then complains it doesn't have permission to write there. How do I change the permissions on the

/var/log/tomcat7 directory?

Posted February 3rd, 2013 04:54

neilh20

I used the "sudo apt-get install tomcat6", and it installed tomcat to /usr/share/tomcat6

There was already installed an OpenJdk IcedTea6 1.12.3 java version "1.6.0_27"

When I did startup.sh - I had the same response

touch: cannot touch `/usr/share/tomcat6/logs/catalina.out': No such file or directory

/usr/share/tomcat6/bin/catalina.sh: 375: /usr/share/tomcat6/bin/catalina.sh: cannot create /usr/share/tomcat6/logs/catalina.out:

Directory nonexistent

However, trying :8080 I got "It worked" for tomcat - so something is coming up. So creating and fixing the

sudo mkdir /usr/share/tomcat6/logs

sudo chown user:user /usr/share/tomcat6/logs

Allowed me to

cat /usr/share/tomcat6/logs/catalina.out

and a few other directories needed creating and populating which got me into more issues.

Then :8080 didn't even respond.

Seems to me that the basic configuration doesn't pull in a working demo - and I'm going back to thinking about it.

I do have a working/production tomcat6 environment on another virtual machine (that some one else setup), and got a version upand going on a local Ubuntu 11.x some time ago - so going to figure out what I did in those environments.

Page 6: How to Install Apache Tomcat on Ubuntu 12

11/1/13 How To Install Apache Tomcat on Ubuntu 12.04 | DigitalOcean

https://www.digitalocean.com/community/articles/how-to-install-apache-tomcat-on-ubuntu-12-04 6/15

Posted March 9th, 2013 05:17

vsc1981

Hi! I have to install Tomcat in order to run my WAR file.

I have installed it using "sudo apt-get install tomcat7".

Because of the posts above I have discovered the path where it has been installed is: "/usr/share/tomcat7"

I have added to "sudo nano ~/.bashrc" the 2 lines you specify.

When I try to run the "$CATALINA_HOME/bin/startup.sh" command it tells me:

"/home/MYUSER/usr/share/tomcat7/bin/startup.sh: No such file or directory"

It adds the "/home/MYUSER/" string to the path and I cannot execute the startup.sh, but for some reason if write

DROPLET_IP:8080 on my browser the tomcat page appears and it seems to work.

Can you help me with this please?

Thanks in advance.

Posted March 14th, 2013 12:35

rajan0913

hi .. i have ubuntu 12.04

i am using the eclipse indigo IDE for developing the php projects with the xampp server

i want to use the same IDE for develop the JAVAEE project...

but i am not able to configure both things

PLEASE give me the instructions for those things please help me !

i am waiting for your reply ..

thanks in advance !

Posted March 18th, 2013 18:21

neilh20

Hell vsc1981 - I'm exploring some of these options as well.

The way I understand it, tomcat is starting up on machine boot from /etc/init.d/tomcat

which sets user:group tomcat6 tomcat6 &

CATALINA_HOME=/usr/share/tomcat6

CATALINA_BASE=/var/lib/tomcat6

and it all works.

>>

sudo apt-get install tomcat6-user tomcat6-instance-create my-instance

Page 7: How to Install Apache Tomcat on Ubuntu 12

11/1/13 How To Install Apache Tomcat on Ubuntu 12.04 | DigitalOcean

https://www.digitalocean.com/community/articles/how-to-install-apache-tomcat-on-ubuntu-12-04 7/15

(answer ENTER to the question)

Now you can install your common libraries in the lib/ subdirectory and deploy your webapps in the webapps/ subdirectory. No

webapps are deployed by default.

Now you need to shutdown tomcat and start my-instance

my-instance/bin/shutdown.sh

my-instance/bin/startup.sh

>>>

HOWEVER, I haven't figured out to do production - get it into the startup $CATALINA_BASE.

This is supposed to be easy through the "manager" package - but it hasn't worked for me. Maybe because I don't have the right

directory IDs for tomcat6.

Posted March 20th, 2013 00:46

neilh20

Oops - in the previous post - I'm using tomcat6 because of a legacy app working in it - so every thing should reference tomcat6,

and my guess is tomcat7 works the same.

Posted March 20th, 2013 00:47

manpreetsidhu88m

Its good........... But where is script to start Apache automatically at Boot time?

Posted June 12th, 2013 06:11

Kamal Nasser

@manpreetsidhu88m do /etc/init.d/tomcat and /etc/init.d/apache2 exist?

Posted June 12th, 2013 08:34

2011chandan

I have installed tomcat7. I followed the exact process described here for installation. I have given the path in bash asCATALINA_HOME=/usr/share/tomcat7. But when I'm trying to activate it using CATALINA_HOME/bin/startup.sh, it throws

No such file or directory found.

Page 8: How to Install Apache Tomcat on Ubuntu 12

11/1/13 How To Install Apache Tomcat on Ubuntu 12.04 | DigitalOcean

https://www.digitalocean.com/community/articles/how-to-install-apache-tomcat-on-ubuntu-12-04 8/15

Below are the paths that I have set in bash file:

export JAVA_HOME=/usr/lib/jvm/default-java

export CATALINA_HOME=/usr/share/tomcat7

Can anyone let me why it is happening?

Posted July 4th, 2013 06:34

Kamal Nasser

@2011chandan Try running /usr/share/tomcat7/bin/startup.sh directly - does that work?

Posted July 4th, 2013 09:42

mseanu

Tell Me to configure Tomcat with php

Posted July 10th, 2013 14:11

Kamal Nasser

@mseanu: PHP 5 is not supported by Tomcat. Tomcat is a java webserver, try installing Apache or Nginx to serve PHP files:

apache: https://www.digitalocean.com/community/articles/how-to-install-linux-apache-mysql-php-lamp-stack-on-ubuntu

or

nginx: https://www.digitalocean.com/community/articles/how-to-install-linux-nginx-mysql-php-lemp-stack-on-ubuntu-12-04

Posted July 10th, 2013 14:14

klimatima

n00b question: i have installed tomcat on my localhost (ubuntu12.04). i can run a war file and so forth. and can then access it

....:8080. so, installing it on DO (it should be similar to how i set it up on my localhost), how then would users be able to view the

app? by going to (e.g. droplet_.com:8080) on their browser?

Posted July 22nd, 2013 19:27

Page 9: How to Install Apache Tomcat on Ubuntu 12

11/1/13 How To Install Apache Tomcat on Ubuntu 12.04 | DigitalOcean

https://www.digitalocean.com/community/articles/how-to-install-apache-tomcat-on-ubuntu-12-04 9/15

Kamal Nasser

@klimatima: Yes, that is correct.

Posted July 23rd, 2013 11:33

bezvezemail

I dont get a page like from a picture. I get "It works If you're seeing this page via a web browser, it means you've setup Tomcat

successfully. Congratulations!.." but how do I get the page from the picture?

Posted July 25th, 2013 08:23

Kamal Nasser

@bezvezemail: This article is a bit old so Tomcat might have changed their default page.

Posted July 25th, 2013 12:00

sandeepbhandari1

Could you pls. also share what if we are unable to start tomcat due to some problem and still want to know the version of tomcatby being offline. I have searched a lot for this but not able to find a way. The other tutorial also proved of some help but still

looking for answer.

Posted July 29th, 2013 07:09

Kamal Nasser

@sandeepbhandari1: "apt-cache show tomcat7" should show you the package's version.

Posted July 29th, 2013 09:11

Page 10: How to Install Apache Tomcat on Ubuntu 12

11/1/13 How To Install Apache Tomcat on Ubuntu 12.04 | DigitalOcean

https://www.digitalocean.com/community/articles/how-to-install-apache-tomcat-on-ubuntu-12-04 10/15

klimatima

i also installed tomcat6 and when i run the "$CATALINA_HOME/bin/startup.sh"

i get this:

-bash: /root/usr/share/tomcat6/bin/startup.sh: No such file or directory

but when i go to 8080, i see the "it works" page, but that's all. going to the manager webapp throws a 404 error.

Posted August 22nd, 2013 15:20

Kamal Nasser

@klimatima: Did you follow this article properly? Please paste the commands you ran (they're stored in ~/.bash_history).

Posted August 23rd, 2013 12:40

nishapmore

Hi,

I followed all the steps you have given. For more clarification:

I run below commands ,

1) sudo apt-get install tomcat7 ( I am successfully installed tomcat7 @ user/share/tomcat7) 2) sudo apt-get install default-jdk ( Successful java installed @ /usr/lib/jvm/default-java)

3) sudo nano ~/.bashrc ( export JAVA_HOME=/usr/lib/jvm/default-java

export CATALINA_HOME=/user/share/tomcat7 added at end of file and saved)

4)~/.bashrc when i hit the enter after this cmd I got an error Permission denied:(

5)$CATALINA_HOME/bin/startup.sh then I got "bash: CATALINA_HOME/bin/startup.sh: No such file or directory

"

6) According to post i ran "/usr/share/tomcat7/bin/startup.sh"

and this time I got below Error log on terminal.

shani@shani-Vostro-2520:~$ /usr/share/tomcat7/bin/startup.sh

Using CATALINA_BASE: /usr/share/tomcat7

Using CATALINA_HOME: /usr/share/tomcat7

Using CATALINA_TMPDIR: /usr/share/tomcat7/temp

Using JRE_HOME: /usr/lib/jvm/default-java

Using CLASSPATH: /usr/share/tomcat7/bin/bootstrap.jar:/usr/share/tomcat7/bin/tomcat-juli.jar

touch: cannot touch `/usr/share/tomcat7/logs/catalina.out': No such file or directory

/usr/share/tomcat7/bin/catalina.sh: 389: /usr/share/tomcat7/bin/catalina.sh: cannot create /usr/share/tomcat7/logs/catalina.out:

Directory nonexistent

Page 11: How to Install Apache Tomcat on Ubuntu 12

11/1/13 How To Install Apache Tomcat on Ubuntu 12.04 | DigitalOcean

https://www.digitalocean.com/community/articles/how-to-install-apache-tomcat-on-ubuntu-12-04 11/15

Please Help me!!!

Posted September 2nd, 2013 13:10

Kamal Nasser

@nishapmore: Are you still experiencing this issue?

Posted September 5th, 2013 19:16

petersonjake

export CATALINA_HOME=/user/share/tomcat7

I created the directory "logs" as well as the file "catalina.out" inside it.....

droplet-ip:8080:

*******************

It works !

If you're seeing this page via a web browser, it means you've setup Tomcat successfully. Congratulations!

This is the default Tomcat home page. It can be found on the local filesystem at: /var/lib/tomcat7/webapps/ROOT/index.html

Posted September 11th, 2013 22:38

Kamal Nasser

Great! :]

Posted September 12th, 2013 13:29

normanitc

I've been working for hours trying to get this to work. If I start up a completely new droplet, it get it to work every time, first try.

However when I try to do this on my droplet that I've already set up with a LAMP stack, and already have a website running with

a mail server, owncloud and all that I always get the error when I try to run $CATALINA_HOME/bin/startup.sh. The error is:

Page 12: How to Install Apache Tomcat on Ubuntu 12

11/1/13 How To Install Apache Tomcat on Ubuntu 12.04 | DigitalOcean

https://www.digitalocean.com/community/articles/how-to-install-apache-tomcat-on-ubuntu-12-04 12/15

-bash: /root/usr/share/tomcat7/bin/startup.sh: No such file or directory

This is following the setup exactly. And like I said when I run this on a fresh droplet it works fine.

Posted September 25th, 2013 01:37

normanitc

After doing research I probably should have done before, do you still have to do some config. to use apache2 with tomcat7?

Posted September 25th, 2013 02:04

Kamal Nasser

@normanitc: See if this helps: http://thetechnocratnotebook.blogspot.co.il/2012/05/installing-tomcat-7-and-apache2-with.html

Posted September 27th, 2013 09:44

ichraf.bouzekri

Hi nishapmore,

I have the same problem. Could you tell me if you have risolved it ??

Posted October 8th, 2013 17:36

ayoubpats

Hi

i have installed tomcat7 and openjdk and when i run the below command it says no such file or directory

CATALINA_HOME/bin/startup.sh

-bash: CATALINA_HOME/bin/startup.sh: No such file or directory

root@pacific:~# usr/share/tomcat7/bin/startup.sh

-bash: usr/share/tomcat7/bin/startup.sh: No such file or directory

when i goto my ipadress:8080 it gives the below mesage .dont know if i can go ahead and deploy my application or not.

Page 13: How to Install Apache Tomcat on Ubuntu 12

11/1/13 How To Install Apache Tomcat on Ubuntu 12.04 | DigitalOcean

https://www.digitalocean.com/community/articles/how-to-install-apache-tomcat-on-ubuntu-12-04 13/15

It works !

If you're seeing this page via a web browser, it means you've setup Tomcat successfully. Congratulations!

This is the default Tomcat home page. It can be found on the local filesystem at: /var/lib/tomcat7/webapps/ROOT/index.html

Tomcat7 veterans might be pleased to learn that this system instance of Tomcat is installed with CATALINA_HOME in

/usr/share/tomcat7 and CATALINA_BASE in /var/lib/tomcat7, following the rules from /usr/share/doc/tomcat7-

common/RUNNING.txt.gz.

You might consider installing the following packages, if you haven't already done so:

tomcat7-docs: This package installs a web application that allows to browse the Tomcat 7 documentation locally. Once installed,

you can access it by clicking here.

tomcat7-examples: This package installs a web application that allows to access the Tomcat 7 Servlet and JSP examples. Once

installed, you can access it by clicking

Posted October 18th, 2013 02:31

Kamal Nasser

@ayoubpats: It should be $CATALINA_HOME/bin/startup.sh, not CATALINA_HOME/bin/startup.sh

Posted October 18th, 2013 14:05

ivelclown

Guys, is the procedure the same in installing apache2 in red hot?

Posted October 24th, 2013 14:14

Kamal Nasser

@ivelclown: No. This article walks you through installing Apache Tomcat on Ubuntu. See

https://www.digitalocean.com/community/articles/how-to-install-linux-apache-mysql-php-lamp-stack-on-centos-6 on how to

install Apache2 on CentOS.

Posted October 24th, 2013 15:46

Page 14: How to Install Apache Tomcat on Ubuntu 12

11/1/13 How To Install Apache Tomcat on Ubuntu 12.04 | DigitalOcean

https://www.digitalocean.com/community/articles/how-to-install-apache-tomcat-on-ubuntu-12-04 14/15

jamesharoldkelley

I ***STRONGLY*** suggest that users also setup CATALINA_BASE environment var while configuring CATALINA_HOME

in their .bashrc file as follows:

CATALINA_HOME=/usr/share/tomcat7

CATALINA_BASE=/var/lib/tomcat7

CATALINA_BASE contains various configurations that are NOT properly picked up (if unset) since CATALINE_BASE

defaults to the same path as CATALINA_HOME and things get very wonky, this would including: startup errors, unable to find

logging directories and doing something as simple as changing Tomcat port from 8080 to 80 will fail miserably because the

autobind property (contained in a configuration file in /var/lib/tomcat7) will be missing/improperly set. Might I suggest that this

additional step be included in the above how-to. (BTW -- figuring this all out took several hours after pouring over the tomcat

manuals before stumbling onto this, while some might have found it faster, I don't think it is at all obvious for any newbie)

Thanks

Posted November 1st, 2013 02:18

Leave a comment

Email

Password

Create your account or sign-in

Post my Comment

Company

Pricing

Comparison Chart

Features

Customers

About

FAQ

Press

Jobs

API

Integrations

Page 15: How to Install Apache Tomcat on Ubuntu 12

11/1/13 How To Install Apache Tomcat on Ubuntu 12.04 | DigitalOcean

https://www.digitalocean.com/community/articles/how-to-install-apache-tomcat-on-ubuntu-12-04 15/15

Network Status

Contact

Community

Articles & Tutorials

Get Paid to Write

Suggest an Article

Chat

Q&A

Blog

Referral Program

Events Calendar

Feedback

Badges & Logos

The Shop

Getting Started

One-Click Install Applications

What is Cloud Hosting?

Control Panel Overview

Deploy a Virtual Server

Set-Up SSH Keys

Install Git on Ubuntu

How to Install Ruby on Rails

How to Install LAMP Stack

Set-Up a Host Name

©2011-2013 DigitalOcean™, Inc. All Rights Reserved. Terms & Privacy. Security.