You are viewing a plain text version of this content. The canonical link for it is here.
Posted to users@tomcat.apache.org by pablo a maurin <pa...@platinum-rx.com> on 2003/04/28 20:58:11 UTC
Apache + mod_jk2 question
Hello flux,
I am trying to install Apache2 with Tomcat and PHP. So far I have
managed to get Apache and PHP successfully installed. I have also
installed and run Tomcat in standalone mode. When I try to use mod_jk2
to connect apache to tomcat I get an "Internal Server Error" reported by
Apache.
I was hoping someone could give me some pointers in figuring this out.
This is what I have done so far.
1. Installed apache2 from source as per the instructions at
http://dan.drydog.com/apache2php.html. Since this machine is running
RedHat 7.3, I used './configure --enable-layout=RedHat ...' for the
installation instead of '.configure --prefix=/usr/local/apache ...'
Well after finishing I had a working Apache2 + PHP4.2.1 with mod_php
installed an working.
Then I began installation of Tomcat as per
"http://jakarta.apache.org/tomcat/tomcat-4.1-doc/RUNNING.txt"
2. Downloaded and untared (installed) the J2SDK v.1.4.1_02 from
'java.sun.com' in /usr/java/j2sdk1.4.1_02
3. Downloaded and installed Tomcat into /usr/local/jakarta-tomcat
folder. From here I can do:
/usr/local/jakarta-tomcat/bin/startup.sh
/usr/local/jakarta-tomcat/bin/shutdown.sh
At this point tomcat runs and I am able to see all the sample pages on
port 8080. http://24.244.141.187:8080 (we are getting a domain name
for this ip)
Now the fun part. I try to install mod_jk2. I have been following the
directions at
"http://jakarta.apache.org/tomcat/tomcat-4.1-doc/jk2/jk2/vhosthowto.html".
Starting from the beggining.
4. Download and config apache, The howto states that the only important
thing is to have --enable-so on the ./configure line for apache. So I
went back to the initial apache install from (1) and confirm that option
is there. It was also important for mod_php. So we move on
5. Install tomcat. I installed in /usr/local/jakarta-tomcat
6. edit the file /usr/local/jakarta-tomcat/conf/server.xml
---- server.xml ---------
<Server port="8005" shutdown="SHUTDOWN" debug="0">
<!-- Define an Apache-Connector Service -->
<Service name="Tomcat-Apache">
<!-- Define a Coyote/JK2 AJP 1.3 Connector on port 8009 -->
<Connector className="org.apache.coyote.tomcat4.CoyoteConnector"
port="8009" minProcessors="5" maxProcessors="75"
enableLookups="true" redirectPort="8443"
acceptCount="10" debug="0" connectionTimeout="20000"
useURIValidationHack="false"
protocolHandlerClassName="org.apache.jk.server.JkCoyoteHandler"/>
<Engine name="Apache" defaultHost="www.my-apps.com" debug="0">
<Logger className="org.apache.catalina.logger.FileLogger"
prefix="apache_log." suffix=".txt"
timestamp="true"/>
<!-- Access log processes all requests for this virtual host. -->
<Valve className="org.apache.catalina.valves.AccessLogValve"
directory="logs" prefix="localhost_access_log."
suffix=".txt"
pattern="common" resolveHosts="false"/>
<Host name="www.my-apps.com" debug="0"
appBase="/var/www/my-apps.com" unpackWARs="true" autoDeploy="true">
<Alias>my-apps.com</Alias>
<Alias>24.244.141.187</Alias>
<Context path="" docBase="" debug="1"/>
<Valve className="org.apache.catalina.valves.AccessLogValve"
directory="logs" prefix="my-apps_access_log."
suffix=".txt"
pattern="common" resolveHosts="false"/>
</Host>
</Engine>
</Service>
</Server>
-------------------------
Then I rtfm'ed vhosts and added the following to /etc/httpd/conf/httpd.conf
--- httpd.conf (snippet) ----------------
# Added by Pablo- 2003-04-27
<VirtualHost 24.244.141.185>
ServerName www.platinum-intimacy.com
ServerAlias platinum-intimacy.com
ServerAdmin webmaster@platinum-intimacy.com
DocumentRoot /var/www/platinum-intimacy.com
ErrorLog /var/log/httpd/platinum-intimacy.com/error_log
CustomLog /var/log/httpd/platinum-intimacy.com/access_log common
</VirtualHost>
<VirtualHost 24.244.141.187>
ServerName www.my-apps.com
ServerAlias my-apps.com
ServerAdmin webmaster@my-apps.com
DocumentRoot /var/www/my-apps.com
ErrorLog /var/log/httpd/my-apps.com/error_log
CustomLog /var/log/httpd/my-apps.com/access_log common
<Location "/*.jsp">
JkUriSet worker ajp13:localhost:8009
</Location>
</VirtualHost>
---------------------------------------------
Then I created /etc/httpd/conf/workers2.properties
----- workers2.properties ------------------
# only at beginnin. In production uncomment it out
[logger.apache2]
level=DEBUG
[shm]
file=/var/log/httpd/shm.file
size=1048576
# Example socket channel, override port and host.
[channel.socket:localhost:8009]
port=8009
host=127.0.0.1
# define the worker
[ajp13:localhost:8009]
channel=channel.socket:localhost:8009
# Uri mapping for using the staight ip
[uri:24.244.141.187/*.jsp]
worker=ajp13:localhost:8009
# Uri mapping
[uri:www.my-apps.com/*.jsp]
worker=ajp13:localhost:8009
----------------------------------------------------
Now I can start apache and tomcat and when I go to the url
"http://www.my-apps.com/numsguess.jsp" I get an internal server error.
BTW, The numguess.jsp file is a copy from the original tomcat jsp
examples folder. I just copied the .jsp file only.
For now I am using entries in my /etc/hosts file, but I am getting the
domain name my-apps.com for this new server and configuring DNS.
If there is any more information that is needed, just let me know. I
tried to compress a little since there where alot of steps that I had to
follow.
Also, could someone explaine how servelets are mapped to URLs? For
example how do I get to http://www.my-apps.com/ThisServelet for example.
Thanks in advance,
-Pablo
---------------------------------------------------------------------
To unsubscribe, e-mail: tomcat-user-unsubscribe@jakarta.apache.org
For additional commands, e-mail: tomcat-user-help@jakarta.apache.org
Re: Apache + mod_jk2 question
Posted by pablo a maurin <pa...@platinum-rx.com>.
Thanks for the prompt reply. I made a few changes which I believe are
in the right direction (clearly I am a roockie at this)
> OK, you copied the JSP file. How/where did you copy it? You can't
> just drop a JSP into a directory and run it like you can a PHP file.
> JSPs are compiled into servlets, thus they need the full servlet
> container arrangement.
>
> It looks like you probably copied the JSP file to
> /var/www/my-apps.com. Do you have a WEB-INF directory there? Do you
> have a web.xml file?
Now I do.
This make much more sense. So what I did is create a folder "servlet"
in /var/www/my-apps.com/. With in this folder I will create the webapp
that is to be run. If I understand this correctly I will be able to
then have apache handle all file from /var/www/my-apps.com
(http://www.my-apps.com) and to have tomcat handle all JSP/Servelets
from /var/www/my-apps.com/servlet (http://www.my-apps.com/servlet). Is
this correct? On another machine, if I run Tomcat standalone with the
above "servlet" folder I am able to access
http://machine.edu:8080/servlet/hello (a servlet) and
http://machine.edu/servlet/numguess.jsp. From the computer running
apache I can also access the php file. This is very nice.
So I think that the directory stucture is now good.
[pablo@avalon www]$ pwd
/var/www
[pablo@avalon www]$ tree -x my-apps.com/
my-apps.com/
|-- index.html
|-- servlet
| |-- WEB-INF
| | |-- classes
| | | |-- num
| | | | |-- NumberGuessBean.class
| | | | `-- NumberGuessBean.java
| | | `-- org
| | | `-- maurin
| | | `-- servlet_test
| | | `-- servlet
| | | |-- Counter.class
| | | `-- Hello.class
| | `-- web.xml
| `-- numguess.jsp
`-- test
|-- index.html
|-- index2.html
`-- test.php
>
>
> Did you try accessing http://your.host.com/examples/???? I would do
> that before trying to make a bunch of changes...you'll want to put the
> correct URL map in workers2.properties for /examples.
Now when I go to http://www.my-apps.com/servlet/hello I get a message
from apache that the above url is not found. When I check the apache
logs, I see it is tring to open the file
/var/ww/my-apps.com/servelet/hello. Clearly this file does not exist.
Instead, it should launch the servlet Hello.class. That is what I
specified in the web.xml file and it works from the standalone servre.
So I am missing something in the instructions for apache to use the
servlet container. If I go to
http://www.my-apps.com/servlet/numguess.jsp Apache reports an internal
server error. Any suggestions?
Thanks for all the help so far. Now I hope I can figure this out.
--- current /etc/httpd/conf/workers2.properties --------------
# only at beginnin. In production uncomment it out
[logger.apache2]
level=DEBUG
[shm]
file=/var/log/httpd/shm.file
size=1048576
# Example socket channel, override port and host.
[channel.socket:localhost:8009]
port=8009
host=127.0.0.1
# define the worker
[ajp13:localhost:8009]
channel=channel.socket:localhost:8009
# Uri mapping for using the staight ip
[uri:24.244.141.187/servlet/*]
worker=ajp13:localhost:8009
# Uri mapping
[uri:www.my-apps.com/servlet/*]
worker=ajp13:localhost:8009
# Uri mapping
[uri:my-apps.com/servlet/*]
worker=ajp13:localhost:8009
--------------------------------------------------------
-------- current /usr/local/jakarta-tomcat/conf/server.xml ---------------
<!-- Tomcat Server Configuration File -->
<Server port="8005" shutdown="SHUTDOWN" debug="0">
<!-- Define an Apache-Connector Service -->
<Service name="Tomcat-Apache">
<!-- Define a Coyote/JK2 AJP 1.3 Connector on port 8009 -->
<Connector className="org.apache.coyote.tomcat4.CoyoteConnector"
port="8009" minProcessors="5" maxProcessors="75"
enableLookups="true" redirectPort="8443"
acceptCount="10" debug="0" connectionTimeout="20000"
useURIValidationHack="false"
protocolHandlerClassName="org.apache.jk.server.JkCoyoteHandler"/>
<Engine name="Apache" defaultHost="www.my-apps.com" debug="0">
<Logger className="org.apache.catalina.logger.FileLogger"
prefix="apache_log." suffix=".txt"
timestamp="true"/>
<!-- Access log processes all requests for this virtual host. -->
<Valve className="org.apache.catalina.valves.AccessLogValve"
directory="logs" prefix="localhost_access_log."
suffix=".txt"
pattern="common" resolveHosts="false"/>
<Host name="www.my-apps.com" debug="0"
appBase="/var/www/my-apps.com/servlet" unpackWARs="true" autoDeploy="true">
<Alias>my-apps.com</Alias>
<Alias>24.244.141.187</Alias>
<Context path="" docBase="" debug="1"/>
<Valve className="org.apache.catalina.valves.AccessLogValve"
directory="logs" prefix="my-apps_access_log."
suffix=".txt"
pattern="common" resolveHosts="false"/>
</Host>
</Engine>
</Service>
</Server>
----------------------------------------------------------------------------
-------- /etc/httpd/conf/http.conf (snippet) -------------------------------
# Added by Pablo- 2003-04-27
<VirtualHost 24.244.141.187>
ServerName www.my-apps.com
ServerAlias my-apps.com
ServerAdmin webmaster@my-apps.com
DocumentRoot /var/www/my-apps.com
ErrorLog /var/log/httpd/my-apps.com/error_log
CustomLog /var/log/httpd/my-apps.com/access_log common
<Location "/*.jsp">
JkUriSet worker ajp13:localhost:8009
</Location>
---------------------------------------------------------------------------------
---------------------------------------------------------------------
To unsubscribe, e-mail: tomcat-user-unsubscribe@jakarta.apache.org
For additional commands, e-mail: tomcat-user-help@jakarta.apache.org
Re: Apache + mod_jk2 question
Posted by John Turner <to...@johnturner.com>.
OK, you copied the JSP file. How/where did you copy it? You can't just
drop a JSP into a directory and run it like you can a PHP file. JSPs are
compiled into servlets, thus they need the full servlet container
arrangement.
It looks like you probably copied the JSP file to /var/www/my-apps.com. Do
you have a WEB-INF directory there? Do you have a web.xml file?
Did you try accessing http://your.host.com/examples/???? I would do that
before trying to make a bunch of changes...you'll want to put the correct
URL map in workers2.properties for /examples.
John
On Mon, 28 Apr 2003 14:58:11 -0400, pablo a maurin <pa...@platinum-rx.com>
wrote:
> Hello flux,
>
> I am trying to install Apache2 with Tomcat and PHP. So far I have
> managed to get Apache and PHP successfully installed. I have also
> installed and run Tomcat in standalone mode. When I try to use mod_jk2
> to connect apache to tomcat I get an "Internal Server Error" reported by
> Apache.
>
> I was hoping someone could give me some pointers in figuring this out.
>
> This is what I have done so far.
>
> 1. Installed apache2 from source as per the instructions at
> http://dan.drydog.com/apache2php.html. Since this machine is running
> RedHat 7.3, I used './configure --enable-layout=RedHat ...' for the
> installation instead of '.configure --prefix=/usr/local/apache ...' Well
> after finishing I had a working Apache2 + PHP4.2.1 with mod_php installed
> an working.
>
> Then I began installation of Tomcat as per
> "http://jakarta.apache.org/tomcat/tomcat-4.1-doc/RUNNING.txt"
>
> 2. Downloaded and untared (installed) the J2SDK v.1.4.1_02 from
> 'java.sun.com' in /usr/java/j2sdk1.4.1_02
> 3. Downloaded and installed Tomcat into /usr/local/jakarta-tomcat folder.
> From here I can do:
> /usr/local/jakarta-tomcat/bin/startup.sh
> /usr/local/jakarta-tomcat/bin/shutdown.sh
>
> At this point tomcat runs and I am able to see all the sample pages on
> port 8080. http://24.244.141.187:8080 (we are getting a domain name for
> this ip)
>
> Now the fun part. I try to install mod_jk2. I have been following the
> directions at "http://jakarta.apache.org/tomcat/tomcat-4.1-
> doc/jk2/jk2/vhosthowto.html". Starting from the beggining.
>
> 4. Download and config apache, The howto states that the only important
> thing is to have --enable-so on the ./configure line for apache. So I
> went back to the initial apache install from (1) and confirm that option
> is there. It was also important for mod_php. So we move on
> 5. Install tomcat. I installed in /usr/local/jakarta-tomcat
> 6. edit the file /usr/local/jakarta-tomcat/conf/server.xml
>
> ---- server.xml ---------
> <Server port="8005" shutdown="SHUTDOWN" debug="0">
> <!-- Define an Apache-Connector Service -->
> <Service name="Tomcat-Apache">
> <!-- Define a Coyote/JK2 AJP 1.3 Connector on port 8009 -->
> <Connector className="org.apache.coyote.tomcat4.CoyoteConnector"
> port="8009" minProcessors="5" maxProcessors="75"
> enableLookups="true" redirectPort="8443"
> acceptCount="10" debug="0" connectionTimeout="20000"
> useURIValidationHack="false"
> protocolHandlerClassName="org.apache.jk.server.JkCoyoteHandler"/>
> <Engine name="Apache" defaultHost="www.my-apps.com" debug="0">
> <Logger className="org.apache.catalina.logger.FileLogger"
> prefix="apache_log." suffix=".txt"
> timestamp="true"/>
> <!-- Access log processes all requests for this virtual host. -->
> <Valve className="org.apache.catalina.valves.AccessLogValve"
> directory="logs" prefix="localhost_access_log." suffix=".txt"
> pattern="common" resolveHosts="false"/>
> <Host name="www.my-apps.com" debug="0" appBase="/var/www/my-apps.com"
> unpackWARs="true" autoDeploy="true">
> <Alias>my-apps.com</Alias>
> <Alias>24.244.141.187</Alias>
> <Context path="" docBase="" debug="1"/>
> <Valve className="org.apache.catalina.valves.AccessLogValve"
> directory="logs" prefix="my-apps_access_log." suffix=".txt"
> pattern="common" resolveHosts="false"/>
> </Host>
> </Engine>
> </Service>
> </Server>
> -------------------------
>
> Then I rtfm'ed vhosts and added the following to
> /etc/httpd/conf/httpd.conf
>
> --- httpd.conf (snippet) ----------------
>
> # Added by Pablo-2003-04-27
> <VirtualHost 24.244.141.185>
> ServerName www.platinum-intimacy.com
> ServerAlias platinum-intimacy.com
> ServerAdmin webmaster@platinum-intimacy.com
> DocumentRoot /var/www/platinum-intimacy.com
> ErrorLog /var/log/httpd/platinum-intimacy.com/error_log
> CustomLog /var/log/httpd/platinum-intimacy.com/access_log common
> </VirtualHost>
>
> <VirtualHost 24.244.141.187>
> ServerName www.my-apps.com
> ServerAlias my-apps.com
> ServerAdmin webmaster@my-apps.com
> DocumentRoot /var/www/my-apps.com
> ErrorLog /var/log/httpd/my-apps.com/error_log
> CustomLog /var/log/httpd/my-apps.com/access_log common
>
> <Location "/*.jsp">
> JkUriSet worker ajp13:localhost:8009
> </Location>
>
> </VirtualHost>
> ---------------------------------------------
>
>
> Then I created /etc/httpd/conf/workers2.properties
>
> ----- workers2.properties ------------------
> # only at beginnin. In production uncomment it out
> [logger.apache2]
> level=DEBUG
>
> [shm]
> file=/var/log/httpd/shm.file
> size=1048576
>
> # Example socket channel, override port and host.
> [channel.socket:localhost:8009]
> port=8009
> host=127.0.0.1
>
> # define the worker
> [ajp13:localhost:8009]
> channel=channel.socket:localhost:8009
>
> # Uri mapping for using the staight ip
> [uri:24.244.141.187/*.jsp]
> worker=ajp13:localhost:8009
>
> # Uri mapping
> [uri:www.my-apps.com/*.jsp]
> worker=ajp13:localhost:8009
> ----------------------------------------------------
>
> Now I can start apache and tomcat and when I go to the url
> "http://www.my-apps.com/numsguess.jsp" I get an internal server error.
> BTW, The numguess.jsp file is a copy from the original tomcat jsp
> examples folder. I just copied the .jsp file only.
>
> For now I am using entries in my /etc/hosts file, but I am getting the
> domain name my-apps.com for this new server and configuring DNS.
>
> If there is any more information that is needed, just let me know. I
> tried to compress a little since there where alot of steps that I had to
> follow.
> Also, could someone explaine how servelets are mapped to URLs? For
> example how do I get to http://www.my-apps.com/ThisServelet for example.
>
>
> Thanks in advance,
> -Pablo
>
>
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: tomcat-user-unsubscribe@jakarta.apache.org
> For additional commands, e-mail: tomcat-user-help@jakarta.apache.org
>
>
--
Using M2, Opera's revolutionary e-mail client: http://www.opera.com/m2/
---------------------------------------------------------------------
To unsubscribe, e-mail: tomcat-user-unsubscribe@jakarta.apache.org
For additional commands, e-mail: tomcat-user-help@jakarta.apache.org
Re: Apache + mod_jk2 question
Posted by Mark Eggers <it...@yahoo.com>.
Pablo,
If you want to just explore jsp files without creating
an entire web application, you can add something like
the following to your server.xml file.
Add this in your host container.
<Context
className="org.apache.catalina.core.StandardContext"
crossContext="true" reloadable="true"
mapperClass="org.apache.catalina.core.StandardContextMapper"
useNaming="true"
debug="0"
swallowOutput="false"
privileged="false"
wrapperClass="org.apache.catalina.core.StandardWrapper"
docBase="beg-jsp"
cookies="true"
path="/beg-jsp"
cachingAllowed="true"
charsetMapperClass="org.apache.catalina.util.CharsetMapper">
<Logger
className="org.apache.catalina.logger.FileLogger"
debug="0"
verbosity="1"
prefix="localhost_beg-jsp_log."
directory="logs"
timestamp="true" suffix=".txt"/>
</Context>
I apologize for the formatting. It's a limitation of
the mail client I'm using.
This assumes that you have a directory -
$CATALINA_HOME/webapps/beg-jsp/
that you can just 'drop' jsp files into.
That said, I agree with John in that you should create
the appropriate WEB-INF directory and proper web.xml
file so that Tomcat can mount the context.
This becomes necessary with servlets, where you have
to indicate the servlet name, class name, and mapping.
An example of this web.xml file comes with Tomcat in:
http://localhost:8080/tomcat-docs/appdev/web.xml.txt
An outline of the details involved can be found at:
http://localhost:8080/tomcat-docs/appdev/index.html
HTH
/mde/
just my two cents . . . .
__________________________________
Do you Yahoo!?
The New Yahoo! Search - Faster. Easier. Bingo.
http://search.yahoo.com
---------------------------------------------------------------------
To unsubscribe, e-mail: tomcat-user-unsubscribe@jakarta.apache.org
For additional commands, e-mail: tomcat-user-help@jakarta.apache.org