Web Applications-Deployment-Apache

Version 52.1 by pgr on 2009/11/24 09:27
Warning: For security reasons, the document is displayed in restricted mode as it is not the current version. There may be differences and errors due to this.

Overview

In a deployment scenario on Mac OS X, Linux, or Solaris, your applications will most likely be deployed on Apache.  Additionally, if you develop with WODirectConnectEnabled=false (you should, see the Direct Connect section for details), you will be running your application locally through Apache as well.  Apache is a very extensible web server that provides a huge number of capabilities, some of which we will detail here.

Split Install

WebObjects applications are deployed in a "split install".  A split install means that your application code, components, and resources are deployed in one location to be served from your WebObjects application (on OS X, /Library/WebObjects/Applications/YourApp.woa), while your WebServerResources are installed in another location (on OS X, /Library/WebServer/Documents/WebObjects/YourApp.woa/Contents/WebServerResources) to be served directly by Apache.  This provides the optimal performance scenario, as Apache is specifically tuned for serving static content, and it does not make sense to send requests for large binary files through WebObjects if it is not necessary.

modexpires

To get the most performance out of Apache, you should make sure that you have modexpires enabled.  modexpires controls the caching headers that are applied to static resource requests.  Depending on your installation, Apache may default to modexpires disabled, which would cause your end-users' browser to re-request every resource on your site on every page, even if it's a common header graphic.

An example modexpires configuration might look like:


<IfModule mod_expires.c>
  ExpiresActive On
  ExpiresDefault A60
  ExpiresByType image/bmp A3600
  ExpiresByType image/gif A3600
  ExpiresByType image/ief A3600
  ExpiresByType image/jpeg A3600
  ExpiresByType image/png A3600
</IfModule>

You will also need the corresponding type-extension mappings:


<IfModule mod_mime.c>
  AddType image/bmp bmp
  AddType image/gif gif
  AddType image/ief ief
  AddType image/jpeg jpeg
  AddType image/jpeg jpg
  AddType image/jpeg jpe
  ...
</IfModule>

This tells Apache that when a request is made for a type image/gif, the requesting browser will be told not to request the image again for an hour (A3600 = 3600 seconds).

modrewrite

Anyone who has used WebObjects has likely noticed that WebObjects URLs are long http://yoursite.com/cgi-bin/WebObjects/AppName.woa/wa/something.  It is a common request to make these URLs nicer for end-users who are used to just requesting http://yoursite.com.  Fortunately Apache provides an amazingly extensive module called "modrewrite" that allows you to rewrite the URL requests of your site based on a series of regular expressions and rules.

Aaron Rosenzweig has a very thorough article about using modrewrite with Apache

modrewrite with modwebobjects

I ran into a problem with modrewrite when using modWebObjects where modWebObjects had be loaded first or it just wouldn't work properly (it would work fine with cgi-bin adaptor).

So in http.conf, search for modrewrite and change it to:

Unknown macro: noformat. Click on this message for details.

, find again:

Unknown macro: noformat. Click on this message for details.

There's still a load module in /System/Library/WebObjects/Adaptors/Apache/apache.conf, but you can just ignore it - it produces a warning about being loaded twice.

Mike Schrag

Here's an example modrewrite we use on one of our apps:


<IfModule mod_rewrite.c>
  
RewriteEngine On
  
RewriteRule ^/$ /page/HomePage [R]
  
RewriteCond %{QUERY_STRING} ^appNum=([-0-9]+)(.*)$
  
RewriteRule ^/page/(.*)$ /cgi-bin/WebObjects/AppName.woa/%1/wa/viewPage?pageName=$1%2 [L,PT]
  
RewriteRule ^/page/(.*)$ /cgi-bin/WebObjects/AppName.woa/wa/viewPage?pageName=$1 [L,PT,QSA]
</IfModule>

The WOA produces URLs in the format http://site.com/page/HomePage?appNum=2, which turns into http://site.com/cgi-bin/WebObjects/AppName.woa/2/viewPage?pageName=HomePage.

Invalid macro parameters used for the [id] macro. Cause: [Property [name] mandatory]. Click on this message for details.

WebObjects Adaptor for Apache 2.2

Travis Cripps

A number of people have expressed interest in using the WebObjects adaptor with Apache 2.2.x.  I finally gotten a chance to sit down and work on it today.  I'm writing to let you know that it's available in the Project Wonder CVS repository. (also there are precompiled binaries for various OS available)

The necessary changes turned out to be mostly minor updates to change calls to outdated/deprecated functions.  The biggest (and non-trivial) change was for SSL support.  It's been re-written to use Apache's modssl module.

I've tested with MacOS X 10.4.7, Apache 2.2.2, with and without ssl support.  It works in all of my tests.

Configuration of the web server to work with the adaptor turned out to be surprisingly challenging, due to the new, very strict default access rules that ship in Apache 2.2.x httpd.conf file.  Once I discovered that, it was trivial to change the setting, but it's worth mentioning here to save some people a lot of frustration.

The new default configuration is:


<Directory />
   Options FollowSymLinks
   AllowOverride None
   Order deny,allow
   Deny from all
</Directory>

Your options are to comment out the last 2 lines of that block, or to override them in a VirtualHost block.  Just setting the usual Location block didn't seem to work for me.

And, of course, either change the name of the WebObjectsAlias setting from /cgi-bin/WebObjects to <foo>/WebObjects or comment out the ScriptAlias definition for the /cgi-bin/ directory.

Information
Note

The default Unknown macro: ScriptAlias. Click on this message for details.

Other than these tips, it's pretty much the standard compilation and installation, and configuration.

  1. Alter the make.config file in the Adaptors directory of the Wonder repository to reflect your apache installation setup.
  2. Run make to build the Adaptor
  3. Curse because of that one setting you forgot.  Fix it.
  4. make clean; make
  5. Install the modWebObjects module with apxs
  6. Configure your httpd.conf and either link or copy the WebObjects directory from the standard location (if on MacOS X) to your new htdocs directory.
  7. apachectl configtest; apachectl graceful
  8. Test.
  9. Curse again.  Change the httpd.conf file as necessary.
  10. apachectl graceful.  Go to 8 as necessary.
  11. Finally  apachectl graceful

Enjoy your shiny new WO adaptor. :-)

  • Note: if you are getting the error

Unknown macro: noformat. Click on this message for details.

Add to the end of your make.config the following:
CC = gcc