Community site: login faq


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?


asked 19 Jun '11, 05:08

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:


(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


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:


(20 Sep '11, 20:12) neeravk

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

Here's how you can install Tomcat:

The easy way:

Use this installer: Tomcat install script for WebFaction

The manual way:

  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:


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:


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.

permanent link
This answer is marked "community wiki".

answered 19 Jun '11, 09:44

accept rate: 37%

edited 15 Mar '16, 21:09

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

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

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

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

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

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

Thanks, updated.

(18 Jan '12, 12:58) seanf

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?



(20 Feb '12, 09:32) alfreale

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

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.



(20 Feb '12, 10:20) alfreale

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

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 - updated, thanks for the catch!

(27 Feb '12, 19:11) seanf

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

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


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

permanent link

answered 27 Nov '12, 12:16

iliasr ♦♦
accept rate: 34%

edited 23 Aug '15, 14:15

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

(07 Dec '12, 05:12) robsws

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

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

Hi is this script still working? "There was an error creating the app with the custom script." Any ideas?

(05 Jun '15, 13:54) reylibutan

It looks like Tomcat has released a new version and removed the old one from their mirrors, thus the script can't find the tar archive to install.

You should be able to change line 51 with the new url and get this working.

I'll update the script to use a self-hosted archive on Monday.

(05 Jun '15, 14:13) iliasr ♦♦

You should open an issue with the installer at https://bitbucket.org/kboi/webfaction-tomcat-installer/issues

(05 Jun '15, 14:19) aaront ♦♦
showing 5 of 6 show 1 more comments
Your answer
toggle preview

Follow this question

By Email:

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



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

Question tags:


question asked: 19 Jun '11, 05:08

question was seen: 22,144 times

last updated: 15 Mar '16, 21:09