# tomcat and apache

## eamonn

i have emerged tomcat and i go to http://192.168.70.28:8080/ and it shows tomcat as up. i go to http://192.168.70.28:8080/manager/status and it doesnt work.  i get HTTP Status 403 - Access to the requested resource has been denied.

any ideas?

i am very new to tomcat and i have an app that works on a friends tomcat server that i want to use.  i have searched the forums and followed a couple of guide and nothing seems to work on my setup.  is there any working guides on how to use tomcat and how to use it as an apache2 module please?

----------

## marcolovato

Hi. I think you are going too fast!!!

1) Tomcat is installed and running. Good.

2) Did you create a new context? The "manager" one is used for another purpose... You should create one for your new app.

3) Once did that, you can configure apache to act as a proxy, so your requests go to 80 and apache redirects them internally.

4) ... as an Apache2 module???

You CAN use "manager", but since you are in "learning-mode", you should start by the right way.

Give me more details, and I can provide you some help...

Marco

----------

## j-m

I suggest using mod_jk, ebuild can be found in Bugzilla.

----------

## Sorcerer'sApprentice

Have you tried https://192.168.70.28:8080/manager/status ? Maybe it will only let you access admin pages over a secure connection.

----------

## marcolovato

 *j-m wrote:*   

> I suggest using mod_jk, ebuild can be found in Bugzilla.

 

Yeah. JK works pretty well.

----------

## eamonn

i have created the ebuild file as:

touch mod_jk-1.28.8.ebuild

nano -w mod_jk-1.28.8.ebuild

c&p from https://bugs.gentoo.org/attachment.cgi?id=50889&action=view to the file

chmod a+x mod_jk-1.28.8.ebuild

ebuild mod_jk-1.28.8.ebuild install

and i get 

```

!!! aux_get(): ebuild path for '/mod_jk-1.28.8' not specified:

!!!            None

!!! aux_get(): ebuild path for '/mod_jk-1.28.8' not specified:

!!!            None

```

----------

## moldarion

 *eamonn wrote:*   

> i have emerged tomcat and i go to http://192.168.70.28:8080/ and it shows tomcat as up. i go to http://192.168.70.28:8080/manager/status and it doesnt work.  i get HTTP Status 403 - Access to the requested resource has been denied.
> 
> 

 

The manager application bundled with Tomcat can only be accessed by a user with the role "manager". By default no such user exists (for obvious security reasons), so you'll have to create a new user in /etc/tomcat5/tomcat-users.xml like this:

```
<?xml version='1.0' encoding='utf-8'?>

<tomcat-users>

  <role rolename="tomcat"/>

  <role rolename="role1"/>

  <role rolename="manager"/>

  <user username="tomcat" password="tomcat" roles="tomcat"/>

  <user username="both" password="tomcat" roles="tomcat,role1"/>

  <user username="role1" password="tomcat" roles="role1"/>

  <user username="yourunsername" password="yourpassword" roles="manager"/>

</tomcat-users>

```

----------

## j-m

 *eamonn wrote:*   

> i have created the ebuild file as:
> 
> touch mod_jk-1.28.8.ebuild
> 
> nano -w mod_jk-1.28.8.ebuild
> ...

 

Check how to create a custom ebuild at Gentoo Wiki. The way you tried can´t work.

----------

## eamonn

i put it in /usr/portage/net-www/ 

and did 

ebuild ....mod_jk-1.2.8.ebuild  digest

then 

ebuild .......mod_jk-1.2.8.ebuild  merge

do i need to patch it with that file and do i need those conf files??

----------

## marcolovato

I think this is easier...

a) download my mod_jk.conf

b) download my workers.properties

c) edit mod_jk.conf and put it in /etc/apache2/conf

d) edit workers.properties and put it in /etc/apache2/conf

e) Add this line to your apache2.conf

```
Include conf/mod_jk.conf
```

f) download mod_jk.so

g) put this file in /usr/lib/apache2/modules

And it is done.

You have to proper edit those config files to get what you really want.

My configuration adds a /mbweb/ virtual folder to main server, and binds it to 192.168.10.101 (localhost!) on port 8009 (this is default for tomcat)

You can add this to a VirtualHost too... It is very similar.

This works for all distros, including windows (but then you have to download mod_jk.dll instead)

Marco

----------

## eamonn

thnx for your help so far

i have tried that and it didnt work

i have gone to the url in my web browser too and get HTTP Status 404 - Servlet is not available

when i go the servlet in the normal way localhost:8080/servletname it still doesnt work. any ideas please??

----------

## eamonn

 *marcolovato wrote:*   

> I think this is easier...
> 
> a) download my mod_jk.conf
> 
> b) download my workers.properties
> ...

 

I got tomcat working.. finally. ebuild didnt work for me!!! but then i did this and it worked first time!! This is a great post! thanks

----------

## Zebbeman

Great post, thanks!

This may not be related, but does anyone knows how to enable .jsp-pages in apache's web root directory?

This is my config:

```

# nano -w /usr/lib/apache2/conf/modules.d/80_mod_jk.conf

LoadModule jk_module /usr/lib/apache2/modules/mod_jk.so

JkWorkersFile /etc/apache2/conf/workers.properties

JkLogFile /var/log/apache2/mod_jk.log

JkLogLevel debug

JkMount /*.jsp default

```

And:

```

# nano -w /etc/apache2/conf/workers.properties

workers.apache_home=/etc/apache2

workers.tomcat_home=/opt/tomcat5

workers.java_home=/opt/sun-jdk-1.4.2.08

ps=/

worker.list=default

worker.default.type=ajp13

worker.default.host=localhost

worker.default.port=8009

worker.default.lbfactor=50

worker.default.cachesize=10

worker.default.cache_timeout=600

worker.default.socket_keepalive=1

worker.default.reclycle_timeout=300

```

When I try to access any .jsp like http://localhost/test.jsp it looks in /opt/tomcat5/webapps/ROOT/. I would like to put my .jsp in the same directory as the rest of the web application - is that possible?

----------

## cleber

 *moldarion wrote:*   

>  *eamonn wrote:*   i have emerged tomcat and i go to http://192.168.70.28:8080/ and it shows tomcat as up. i go to http://192.168.70.28:8080/manager/status and it doesnt work.  i get HTTP Status 403 - Access to the requested resource has been denied.
> 
>  
> 
> The manager application bundled with Tomcat can only be accessed by a user with the role "manager". By default no such user exists (for obvious security reasons), so you'll have to create a new user in /etc/tomcat5/tomcat-users.xml like this:
> ...

 

As a mater of fact, you got to have a valid username on there (not on your system, but on the app), so you have to get a user root, as seen:

```

<?xml version='1.0' encoding='utf-8'?>

<tomcat-users>

  <role rolename="tomcat"/>

  <role rolename="role1"/>

  <role rolename="manager"/>

  <role rolename="admin"/>

  <user username="tomcat" password="tomcat" roles="tomcat"/>

  <user username="both" password="tomcat" roles="tomcat,role1"/>

  <user username="role1" password="tomcat" roles="role1"/>

  <user username="root" password="yourpassword" roles="admin,manager"/>

</tomcat-users>

```

----------

