Submit Hint Search The Forums LinksStatsPollsHeadlinesRSS
14,000 hints and counting!

Enable JSP files on port 80 in OS X Server OS X Server
After googling and searching in macosxhints.com without finding a solution, I finally got this to work, so I hope this may help others. The problem I had was that I could not get JSP files to be served on port 80. When I started Tomcat, I could only see Tomcat's examples, which are on port 9006. There may be a better solution, but being new to Tomcat, this is how I solved it. If someone else has a better solution I'd be happy to hear from you.

Here's what I did:
  1. Enable the jk_module for Apache. This is activated in Server Admin -> Web -> Setting -> Modules. Select the enabled checkbox by the jk_module and hit Save. This will restart the Apache server.

  2. Copy from /Library/Tomcat the conf, logs, temp, webapps and work directories to your sites folder -- e.g. /Library/WebServer/Documents. You should now have:
    /Library/WebServer/Documents/conf
    /Library/WebServer/Documents/logs
    /Library/WebServer/Documents/temp
    /Library/WebServer/Documents/webapps
    /Library/WebServer/Documents/work
    
    Each directory would have all their contents, too.

  3. I created a web directory to hold my jsp files (/Library/WebServer/Documents/web). And placed my JSP files in there.

  4. You'll need to run a new instance of Tomcat on port 80, so you need to edit you new server.xml file for your Tomcat instance:
    pico /Library/WebServer/Documents/conf/server.xml
    
    Find where it says port 9006 and change it to port 80. You'll also need to change the examples directory your "web" directory for Tomcat to look for JSP files. Find:
    <Connector className="org.apache.coyote.tomcat4.CoyoteConnector"
                   port="9006" minProcessors="5" maxProcessors="75"
    
    Replace with:
    <Connector className="org.apache.coyote.tomcat4.CoyoteConnector"
                   port="80" minProcessors="5" maxProcessors="75"
    
    Find:
            <!-- Tomcat Examples Context -->
            <Context path="/examples" docBase="web" debug="0"
                     reloadable="true" crossContext="true">
    
    Replace with:
            <!-- Tomcat Examples Context -->
            <Context path="/web" docBase="web" debug="0"
                     reloadable="true" crossContext="true">
    
    Find:
    WebAppDeploy examples warpConnection /examples/
    Replace with:
    WebAppDeploy web warpConnection /web/
  5. Create a script called mytomcat.sh to start Tomcat using your website folder as base directory:
    #!/bin/sh
    
    # set the environment
    
    CATALINA_BASE=/Library/WebServer/Documents
    CATALINA_HOME=/Library/Tomcat
    JAVA_HOME=/Library/Java/Home
    JAVA_OPTS=-server
    
    export CATALINA_BASE CATALINE_HOME JAVA_HOME JAVA_OPTS
    
    exec "$CATALINA_HOME"/bin/catalina.sh "$@"
    
  6. Give mytomcat.sh execute permisions":
    chmod 755 mytomcat.sh
    
  7. Restart Tomcat.
    sudo ./mytomcat.sh stop
    sudo ./mytomcat.sh start
    
That's it, you should now be able to run jsp files from your site: http://www.yourdomain.com/web/test.jsp
    •    
  • Currently 2.11 / 5
  You rated: 3 / 5 (9 votes cast)
 
[15,695 views]  

Enable JSP files on port 80 in OS X Server | 3 comments | Create New Account
Click here to return to the 'Enable JSP files on port 80 in OS X Server' hint
The following comments are owned by whoever posted them. This site is not responsible for what they say.
Probably not what you want to do...
Authored by: escowles on Feb 04, '05 10:48:36AM

This configures tomcat to run on port 80 -- which is fine for a small site, but probably not what you want to do for a production website.

You should load jk_module and setup workers.properties to point to the AJP1.3 instance that tomcat runs (typically on port 8009). Then, apache will serve most normal content as before (including PHP, CGI, etc. which tomcat can't handle, and static files which apache will be much more efficient for). But your webapps will be mounted under the root.

Just make a war file and place it in $CATALINA_HOME/webapps and then restart tomcat. Tomcat will automatically unpack the war file, setup the webapp, and mount it under the root so you can still access it as www.yourdomain.org/web/foo.jsp as before.

Alternatively, if you want to run tomcat on port 80, all you need to do is change the default HttpConnector port from 8080 to 80, and everything will work for tomcat. You'll need to put all your static files under $CATALINA_HOME/webapps/ROOT/ instead of /Library/WebServer/Documents/, though.

-Esme



[ Reply to This | # ]
Enable JSP files on port 80 in OS X Server
Authored by: mephisto on Feb 04, '05 05:32:47PM

As the previous poster stated this is not exactly the best of ways to go for setting up Tomcat.

For using mod_jk with Tomcat I would read this:
http://www.onjava.com/pub/a/onjava/2002/11/20/tomcat.html

For using mod_jk with JBoss read this:
http://www.jboss.org/wiki/Wiki.jsp?page=UsingMod_jk1.2WithJBoss

(I am not particularly thrilled with the jkmount of /* in the JBoss example but it will get you started. IMHO you are better off setting up individual mounts for your web apps... i.e. /examples/* )



[ Reply to This | # ]
Enable JSP files on port 80 in OS X Server
Authored by: ms_t_rie on Feb 07, '05 12:12:03PM

With some trial and error, and looking at the onjava page suggested above (which goes through too much work as I found out!) I figured out that on Panther, which already has Apache installed, you can just use the mod_jk module, and edit /etc/httpd/httpd.conf to put lines similar to these at the bottom:

JkWorkersFile /Developer/jakarta-tomcat-5.5.4/conf/workers.properties
JkLogFile /Developer/jakarta-tomcat-5.5.4/logs/mod_jk.log
JkLogLevel debug
Alias /servlets-examples /Developer/jakarta-tomcat-5.5.4/webapps/servlets-examples
JkMount /servlets-examples/servlet/* ajp13
JkMount /servlets-examples/*.jsp ajp13
Alias /jsp-examples /Developer/jakarta-tomcat-5.5.4/webapps/jsp-examples
JkMount /jsp-examples/servlet/* ajp13
JkMount /jsp-examples/*.jsp ajp13
<Location "/WEB-INF/">
AllowOverride None
deny from all
</Location>

The onjava.com walkthrough is very difficult to follow IMO, it didn't match my Panther setup at all, so I was left floundering trying to find out where to enter commands. And, as it turns out, the default Tomcat configuration already does all the Tomcat side setup, all you have to do is tell Apache to use it. (onjava goes through a bunch of stuff on workers and setting that up, the Tomcat install that I have had already done that, trying to do what onjava suggested broke it actually!)

to get mod_jk itself installed, I ended up downloading the binary and copying the mod_jk.so file to /usr/libexec/httpd. Then I added the lines for mod_jk to httpd.conf as well, I supposed they could be done at the bottom with the other stuff, but I found other sections for similar stuff and added them there.

LoadModule jk_module libexec/mod_jk.so
AddModule mod_jk.c

There's still probably an even better way to do this, but this way seemed much cleaner than the first method (coming from a BEA on Solaris background, I am not very familiar with Apache yet and couldn't even run Server Admin to try it anyways) although it seems like every webapp would require editing httpd.conf and a restart of Apache. (on Panther, "apachectl restart" will restart it from the command line)



[ Reply to This | # ]