1
4

Hi,

I'm looking for a tutorial for installing Apache Tomcat on my webfaction site. Or has anyone successfully done this before and can explain it in detail?

Thanks!

asked 19 Jun '11, 05:08

spatial's gravatar image

spatial
1112
accept rate: 0%

First off, thanks so much for posting this tutorial. When I realized I was going to have to install tomcat on WebFaction myself I felt somewhat at sea, since I have no experience with that particular environment. This tutorial gave me hope, however.

Unfortunately, I haven't been able to successfully reach the "If you're seeing this, you've successfully installed Tomcat. Congratulations!" page. I defined an app in the WF admin system so that tomcat would be running on port #19461. However, when I did that, installed apache tomcat, and started it up, the following URL did not work as expected:

http://sandhillecon.webfactional.com:19461

(I've also tried adding various combinations of webapps or tomcat to the URL, but to no avail.)

I have the following set in server.xml:

  <Host name="sandhillecon.webfactional.com" appBase="webapps"
        unpackWARs="true" autoDeploy="true">

I originally had host name="localhost" but made the above change after reading the documentation at http://tomcat.apache.org/tomcat-5.5-doc/config/host.html.

I believe that I have tomcat running. When I start it up I receive the following:

[sandhillecon@web195 tomcat]$ ~/webapps/tomcat/bin/startup.sh Using CATALINA_BASE: /home/sandhillecon/webapps/tomcat Using CATALINA_HOME: /home/sandhillecon/webapps/tomcat Using CATALINA_TMPDIR: /home/sandhillecon/webapps/tomcat/temp Using JRE_HOME: /usr/lib/jvm/jre-1.6.0-openjdk Using CLASSPATH: /home/sandhillecon/webapps/tomcat/bin/bootstrap.jar:/home/sandhillecon/webapps/tomcat/bin/tomcat-juli.jar

nothing that looks like an error, at least to me.

(20 Sep '11, 20:05) Chris Hall Chris%20Hall's gravatar image

Hi,

You would never be able to access your app at http://sandhillecon.webfactional.com:19461 unless you have a dedicated IP and have got us to open that port on the dedicated IP.

Did you add your custom port to one of the sites in the panel?

If not, you will have to do that and the access the site at one of the domains used on port 80 itself since the app i served behind our frontend.

You can see the following for further help:

http://docs.webfaction.com/user-guide/websites.html#create-a-website-with-the-control-panel

(20 Sep '11, 20:12) neeravk neeravk's gravatar image

Ah, okay... I knew I was being stupid. Having added a new URL path to my existing site and pointing it to my tomcat app, http://sandhillecon.webfactional.com/ntrs now shows the Apache tomcat default page.

Thank you!

(21 Sep '11, 14:26) Chris Hall Chris%20Hall's gravatar image

Here's how you can install Tomcat:

  1. Go to Apps in the control panel and create a new 'custom app listening on port' application. Make a note of the port number assigned to the app. You can name the app whatever you want - in this example, let's name it 'tomcat'.

  2. Go to Sites in the control panel and create a site to serve the app you created in step 1.

  3. SSH into your server and run the following commands:

        cd ~
        if [ "uname -i" = "x86_64" ]; then JRE_HOME=/usr/lib/jvm/jre-1.6.0-openjdk.x86_64; else JRE_HOME=/usr/lib/jvm/jre-1.6.0-openjdk; fi
        echo "export JRE_HOME=$JRE_HOME" >> ~/.bashrc
        source ~/.bashrc
        wget http://apache.mirrors.pair.com/tomcat/tomcat-7/v7.0.25/bin/apache-tomcat-7.0.25.tar.gz
        cd ~/webapps/tomcat
        tar zxf ~/apache-tomcat-7.0.25.tar.gz --strip 1

  4. Edit ~/webapps/tomcat/conf/server.xml to change connector port 8080 to the port assigned to your custom app.

You can then start Tomcat by running:

~/webapps/tomcat/bin/startup.sh

Once Tomcat is running, you should see the "If you're seeing this, you've successfully installed Tomcat. Congratulations!" page when you visit the site you created in step 2.

You can stop it by running:

~/webapps/tomcat/bin/shutdown.sh

Note: I don't actually know much about Tomcat other than the steps above. Some things that you might need to work out further:

  • server.xml has definitions for a lot of ports other than the HTTP connector port - you might need to create additional 'custom app listening on port' applications to reserve ports for those purposes. My basic server seemed to work fine without them.

  • These steps will get you only a bare Tomcat server - you'll still need to deploy your own code and do whatever else you need to get your site up and running.

link
This answer is marked "community wiki".

answered 19 Jun '11, 09:44

seanf's gravatar image

seanf ♦♦
8.0k1726
accept rate: 39%

edited 27 Feb '12, 19:10

Thank you very much for this tutorial.

Sadly there are two issues I'm now having trouble with:

  • I can see "If you're seeing this, you've successfully installed Tomcat. Congratulations!". But if I'm clicking on any link, for instance the Manager App, it will redirect me to mysite.com/manager/html and not mysite.com/tomcat/manager/html. Maybe I have to define that one first?

  • If I try to open the site for the Manager App mysite.com/tomcat/manager/html manually, a username and password prompt is shown. Neither my standard login nor the username I set in tomcat/conf/tomcat-users.xml is working there. Any suggestions where to set those details?

Thanks in advance for helping me again.

(19 Jun '11, 12:42) spatial spatial's gravatar image

I think both of those issues might be related to the fact that you're serving your Tomcat app with "/tomcat" as the URL path, but Tomcat itself is configured to use "/" - as a result, any URLs generated by Tomcat are pointing to the root of the domain, eg "mysite.com/" instead of "mysite.com/tomcat/".

After skimming some Google search results and Tomcat docs, I think the solution is to set context paths somewhere in server.xml. I'm not sure of the exact syntax, but maybe this doc will help: Apache Tomcat 7 Configuration Reference (7.0.16) - The Context Container

(19 Jun '11, 13:25) seanf ♦♦ seanf's gravatar image

I've changed <host name="localhost" appbase="webapps" unpackwars="false" autodeploy="false"> to <host name="mysite.com/tomcat" appbase="webapps" unpackwars="false" autodeploy="false"> but it is still pointing to the root. Other variations did not work in total.

(19 Jun '11, 14:00) spatial spatial's gravatar image

Ok, I guess I'm not sure how to fix that. I don't think the change you made is correct, so set that back to whatever it was before you did it.

I think perhaps the settings need to be made in your conf/context.xml file. Again, I don't know exactly how to do it, but perhaps the following will help:

If you're not able to figure it out, then instead of serving your Tomcat app from domain.com/tomcat, you can instead add a subdomain to your domain and create a separate site to serve Tomcat from the root of that subdomain, thus removing any problems caused by serving it from "/tomcat".

Regarding the username and password for the manager app, add the following to conf/tomcat-users.xml, inside of the <tomcat-users>..</tomcat-users> section:

<role rolename="manager-gui"/>
<user username="yourusername" password="yourpassword" roles="manager-gui"/>

Restart your Tomcat after making that change.

(19 Jun '11, 14:32) seanf ♦♦ seanf's gravatar image

Thanks seanf, that worked a treat.

I did get a "Bad gateway" error at first, but then in the server.xml file i changed all references to port 8080 to my new port and all was peachy.

(01 Jul '11, 08:34) chichilatte chichilatte's gravatar image

Thanks for the guide Sean, works well, just one thing the wget address doesn't work. At the time of writing (Jan 17 2012) should be http://apache.mirrors.pair.com/tomcat/tomcat-7/v7.0.23/bin/apache-tomcat-7.0.23.tar.gz

(17 Jan '12, 11:02) Tony Cronin Tony%20Cronin's gravatar image

Thanks, updated.

(18 Jan '12, 12:58) seanf ♦♦ seanf's gravatar image

Hi, thanks for the guide. It's all working except than any links generated by tomcat are pointing to the root of the domain. e.g. mysite instead of mysite/tomcat/

Any suggestion?

Thanks,

Alfredo

(20 Feb '12, 09:32) alfreale alfreale's gravatar image

Hi Alfredo, This seems like the expected behavior. Can you explain in more detail what exactly you are trying to do?

(20 Feb '12, 09:41) todork todork's gravatar image

I've the django application using the url "mysite.com/" and the tomcat application using "mysite.com/geo"

And both of them are working.

But if I try to access at geoserver application installed by tomcat that I can found at the url "mysite.com/geo/geoserver" the tomcat application redirect to "mysite.com/geoserver". And that url is wrong, nothing shows up.

Thanks,

Alfredo

(20 Feb '12, 10:20) alfreale alfreale's gravatar image

That's because Tomcat doesn't know that it's actually being served from /geo, so it doesn't include that in its generated URLs.

I covered this in my earlier comments on this answer - nothing's changed since then. I still don't have a solution, and my recommendation is that you serve your Tomcat app from the root of a separate subdomain, eg geo.mysite.com.

(20 Feb '12, 12:25) seanf ♦♦ seanf's gravatar image

I've just installed tomcat and found a minor change (for me) is needed to the above guide, line reading:

echo "export JRE_HOME=/usr/lib/jvm/jre-1.6.0-openjdk" >> ~/.bashrc

should be

echo "export JRE_HOME=/usr/lib/jvm/jre-1.6.0-openjdk.x86_64" >> ~/.bashrc

(27 Feb '12, 10:08) shoodabean shoodabean's gravatar image

@shoodabean - updated, thanks for the catch!

(27 Feb '12, 19:11) seanf ♦♦ seanf's gravatar image

Getting a Bad gateway for all of my requests. Not sure where to fix it. It seems that all my ports in server.xml are pointing to the one I created in the custom app/website

Am also looking at the JRE_HOME command earlier. It appears I only have 64 bit jre, but somehow that command is only finding that my share is x86. Do I now need to install 32 bit Java? I guess I'm missing many many steps before I even get started.

Fixed the 64 bit issue. Had to look in the /usr directory for what the name of my JRE was.

(04 May '12, 14:56) humanbird humanbird's gravatar image

@humanbird - you currently have a 502 error because your Tomcat server isn't running. There's a good chance that your processes were terminated because you exceeded your RAM allowance.

(04 May '12, 16:14) seanf ♦♦ seanf's gravatar image

After an hour struggle, the obvious-

This should be changed-

if [ "uname -i" = "x86_64" ]; then JRE_HOME=/usr/lib/jvm/jre-1.6.0-openjdk.x86_64; else JRE_HOME=/usr/lib/jvm/jre-1.6.0-openjdk; fi

to-

if [ "uname -i" = "x86_64" ]; then JRE_HOME=/usr/lib/jvm/jre-1.6.0-openjdk.x86_64; else JRE_HOME=/usr/lib/jvm/jre-openjdk; fi

(30 Apr '13, 14:12) imagnity imagnity's gravatar image
showing 5 of 16 show 11 more comments

I've created an one-click Tomcat installer using WebFaction's XML-RPC API.

You can install it if you click here.

You can find some more info about it at the installer's page, as well as an issue tracker for any installer related issues/proposals.

link

answered 27 Nov '12, 12:16

iliasr's gravatar image

iliasr ♦♦
9364
accept rate: 32%

After trying to set up myself and failing, this worked great, thanks!

(07 Dec '12, 05:12) robsws robsws's gravatar image

I have been trying this but I keep getting a message saying that there was an error in the script. Any ideas what could be wrong?

(11 Dec '12, 13:17) dgd24 dgd24's gravatar image

I've tested the script on a couple of test users and it worked without any issue.

Can you please open a support ticket so we can take a closer look at your account and its environment?

(11 Dec '12, 17:52) iliasr ♦♦ iliasr's gravatar image
Your answer
toggle preview

Follow this question

By Email:

Once you sign in you will be able to subscribe for any updates here

By RSS:

Answers

Answers and Comments

Markdown Basics

  • *italic* or _italic_
  • **bold** or __bold__
  • link:[text](http://url.com/ "Title")
  • image?![alt text](/path/img.jpg "Title")
  • numbered list: 1. Foo 2. Bar
  • to add a line break simply add two spaces to where you would like the new line to be.
  • basic HTML tags are also supported

Tags:

×171
×35
×7

Asked: 19 Jun '11, 05:08

Seen: 7,974 times

Last updated: 30 Apr '13, 14:12

Plans & prices    Sign up    Why WebFaction?    Contact us    Affiliate program    Support    Legal    Jobs    Blog    Control panel login
Powered by OSQA
© Copyright 2003-2012 Swarma Limited - WebFaction is a service of Swarma Limited