Last modified by Aaron Rosenzweig on 2020/09/03 22:17

Hide last authors
Pascal Robert 27.1 1 == Overview ==
David Avendasora 19.1 2
Aaron Rosenzweig 63.1 3 In a deployment scenario on Mac OS X, Linux, Solaris or even Windows, your applications will most likely use Apache to server static resources. Additionally, if you develop with WODirectConnectEnabled=false (you **should**, see the [[Direct Connect>>doc:WO.Home.To classify.Development-Direct Connect.WebHome]] 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.
David Avendasora 19.1 4
Pascal Robert 27.1 5 == Split Install ==
David Avendasora 19.1 6
Theodore Petrosky 59.1 7 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, {{code language="none"}}/Library/WebObjects/Applications/{{/code}}//YourApp//{{code language="none"}}{{/code}}{{code language="none"}}.woa{{/code}}), while your {{code language="none"}}WebServerResources{{/code}} are installed in another location (on OS X, {{code language="none"}}/Library/WebServer/Documents/WebObjects/{{/code}}//YourApp//{{code language="none"}}{{/code}}{{code language="none"}}.woa/Contents/WebServerResources{{/code}}) 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.
David Avendasora 19.1 8
Theodore Petrosky 59.1 9 == mod_expires ==
David Avendasora 19.1 10
Theodore Petrosky 59.1 11 To get the most performance out of Apache, you should make sure that you have mod_expires enabled. mod_expires controls the caching headers that are applied to static resource requests. Depending on your installation, Apache may default to mod_expires 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.
David Avendasora 19.1 12
Theodore Petrosky 59.1 13 An example mod_expires configuration might look like:
David Avendasora 19.1 14
Theodore Petrosky 59.1 15 {{code 0="xml"}}
Quinton Dolan 23.1 16 <IfModule mod_expires.c>
17 ExpiresActive On
18 ExpiresDefault A60
19 ExpiresByType image/bmp A3600
20 ExpiresByType image/gif A3600
21 ExpiresByType image/ief A3600
22 ExpiresByType image/jpeg A3600
23 ExpiresByType image/png A3600
24 </IfModule>
David Avendasora 19.1 25
Quinton Dolan 23.1 26 {{/code}}
David Avendasora 19.1 27
28 You will also need the corresponding type-extension mappings:
29
Theodore Petrosky 59.1 30 {{code 0="xml"}}
Quinton Dolan 23.1 31 <IfModule mod_mime.c>
32 AddType image/bmp bmp
33 AddType image/gif gif
34 AddType image/ief ief
35 AddType image/jpeg jpeg
36 AddType image/jpeg jpg
37 AddType image/jpeg jpe
38 ...
39 </IfModule>
David Avendasora 19.1 40
Quinton Dolan 23.1 41 {{/code}}
David Avendasora 19.1 42
43 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).
44
Theodore Petrosky 59.1 45 == mod_rewrite ==
David Avendasora 19.1 46
Theodore Petrosky 59.1 47 Anyone who has used WebObjects has likely noticed that WebObjects URLs are long [[http:~~/~~/yoursite.com/cgi-bin/WebObjects/AppName.woa/wa/something>>url:http://yoursite.com/cgi-bin/WebObjects/AppName.woa/wa/something||shape="rect"]]{{code language="none"}}{{/code}}. It is a common request to make these URLs nicer for end-users who are used to just requesting [[http:~~/~~/yoursite.com>>url:http://yoursite.com||shape="rect"]]{{code language="none"}}{{/code}}. Fortunately Apache provides an amazingly extensive module called "mod_rewrite" that allows you to rewrite the URL requests of your site based on a series of regular expressions and rules.
David Avendasora 19.1 48
karesz 60.1 49 Aaron Rosenzweig has a very thorough article about [[using mod_rewrite with Apache>>url:http://web.archive.org/web/20051216205025/http://www.jewelryluv.com/fashion/pageWithName/ModRewrite/||shape="rect"]][[.>>url:http://www.jewelryluv.com/fashion/pageWithName/ModRewrite/||shape="rect"]]
David Avendasora 19.1 50
Theodore Petrosky 59.1 51 === mod_rewrite with mod_webobjects ===
David Avendasora 19.1 52
Theodore Petrosky 59.1 53 I ran into a problem with mod_rewrite when using mod_WebObjects where mod_WebObjects had be loaded first or it just wouldn't work properly (it would work fine with cgi-bin adaptor).
David Avendasora 19.1 54
Theodore Petrosky 59.1 55 So in http.conf, search for mod_rewrite and change it to:
David Avendasora 19.1 56
Quinton Dolan 23.1 57 {{noformat}}
58 LoadModule WebObjects_module /System/Library/WebObjects/Adaptors/Apache/mod_WebObjects.so
59 LoadModule rewrite_module libexec/httpd/mod_rewrite.so
David Avendasora 19.1 60
Quinton Dolan 23.1 61 {{/noformat}}
David Avendasora 19.1 62
63 , find again:
64
Quinton Dolan 23.1 65 {{noformat}}
66 AddModule mod_WebObjects.c
67 AddModule mod_rewrite.c
David Avendasora 19.1 68
Quinton Dolan 23.1 69 {{/noformat}}
David Avendasora 19.1 70
Pascal Robert 27.1 71 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.
David Avendasora 19.1 72
Pascal Robert 27.1 73 === Mike Schrag ===
David Avendasora 19.1 74
Theodore Petrosky 59.1 75 Here's an example mod_rewrite we use on one of our apps:
David Avendasora 19.1 76
Theodore Petrosky 59.1 77 {{code 0="xml"}}
Quinton Dolan 23.1 78 <IfModule mod_rewrite.c>
79 RewriteEngine On
80 RewriteRule ^/$ /page/HomePage [R]
81 RewriteCond %{QUERY_STRING} ^appNum=([-0-9]+)(.*)$
82 RewriteRule ^/page/(.*)$ /cgi-bin/WebObjects/AppName.woa/%1/wa/viewPage?pageName=$1%2 [L,PT]
83 RewriteRule ^/page/(.*)$ /cgi-bin/WebObjects/AppName.woa/wa/viewPage?pageName=$1 [L,PT,QSA]
84 </IfModule>
David Avendasora 19.1 85
Quinton Dolan 23.1 86 {{/code}}
David Avendasora 19.1 87
Theodore Petrosky 59.1 88 The WOA produces URLs in the format [[http:~~/~~/site.com/page/HomePage?appNum=2>>url:http://site.com/page/HomePage?appNum=2||shape="rect"]]{{code language="none"}}{{/code}}, which turns into [[http:~~/~~/site.com/cgi-bin/WebObjects/AppName.woa/2/viewPage?pageName=HomePage>>url:http://site.com/cgi-bin/WebObjects/AppName.woa/2/viewPage?pageName=HomePage||shape="rect"]]{{code language="none"}}{{/code}}.
David Avendasora 19.1 89
Marc Guenther 29.1 90
Theodore Petrosky 59.1 91
92 {{id name="Apache22Adapter"/}}
93
Ray Kiddy 62.1 94 === Ray Kiddy ===
95
96 This worked for me (September 2020) and seems easier to parse. I wanted to change all of "(% class="nolink" %)http:~/~/opencalaccess.org/cgi-bin/WebObjects/app.woa(%%)/" to "http:~/~/opencalaccess.org/app/" and this worked.
97
98 >RewriteEngine OnRewriteRule ^/$ /app [R]RewriteRule ^/index.html$ /app [R]RewriteRule ^/app(/(.*))?$ /cgi-bin/WebObjects/app.woa$1 [PT,L]
99
100 I inserted this into my file: /etc/apache2/sites-enabled/[[opencalaccess.org>>url:http://opencalaccess.org||shape="rect"]].conf which specifies the values particular to this one domain.
101
102 I added this as arguments to the app:
103
104 (((
105 (% class="Apple-tab-span" %)
106
107 >-Der.extensions.ERXApplication.replaceApplicationPath.pattern=/cgi-bin/WebObjects/app.woa-Der.extensions.ERXApplication.replaceApplicationPath.replace=/app
108
109 And you can, of course, do this in the Properties file as well. Much thanx to Stefan Gärtner on the mailing list (Subject: Re: Apache rules and SSL, 2020/08/27)
110 )))
111
Pascal Robert 57.1 112 === Jeff Schmitz ===
113
Theodore Petrosky 59.1 114 This one stumped me for a couple days, so thought I'd add it. Was trying to add mod_rewrite functionality as described above, and things went well on my dev machine by adding the rewrite rules just to the /etc/apache2/httpd.conf file. However, on the deployment machine I also had to add them to the /etc/apache2/sites/0000_any_.conf file.
Pascal Robert 57.1 115
Pascal Robert 27.1 116 == WebObjects Adaptor for Apache 2.2 ==
David Avendasora 19.1 117
Pascal Robert 27.1 118 === Travis Cripps ===
David Avendasora 19.1 119
Theodore Petrosky 59.1 120 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>>url:http://wocommunity.org/documents/tools/mod_WebObjects/||shape="rect"]] for various OS available)
David Avendasora 19.1 121
Theodore Petrosky 59.1 122 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 mod_ssl module.
David Avendasora 19.1 123
Theodore Petrosky 59.1 124 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.
David Avendasora 19.1 125
Theodore Petrosky 59.1 126 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.
David Avendasora 19.1 127
128 The new default configuration is:
129
Theodore Petrosky 59.1 130 {{code 0="xml"}}
Quinton Dolan 23.1 131 <Directory />
132 Options FollowSymLinks
133 AllowOverride None
134 Order deny,allow
135 Deny from all
136 </Directory>
David Avendasora 19.1 137
Quinton Dolan 23.1 138 {{/code}}
David Avendasora 19.1 139
Theodore Petrosky 59.1 140 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.
David Avendasora 19.1 141
142 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.
143
Pascal Robert 57.1 144 {{info title="Note"}}
Theodore Petrosky 59.1 145 The default {{code language="none"}}ScriptAlias{{/code}} directive in the 10.5 and 10.6 {{code language="none"}}httpd.conf{{/code}} files is:
Pascal Robert 57.1 146
Theodore Petrosky 59.1 147 {{noformat}}
Pascal Robert 57.1 148 ScriptAliasMatch ^/cgi-bin/((?!(?i:webobjects)).*$) "/Library/WebServer/CGI-Executables/$1"
149
Theodore Petrosky 59.1 150 {{/noformat}}
151
152 This prevents {{code language="none"}}/cgi-bin/WebObjects{{/code}} from matching, so no change to {{code language="none"}}WebObjectsAlias{{/code}} or {{code language="none"}}ScriptAlias{{/code}} is necessary.
Pascal Robert 57.1 153 {{/info}}
154
David Avendasora 19.1 155 Other than these tips, it's pretty much the standard compilation and installation, and configuration.
156
Theodore Petrosky 59.1 157 1. Alter the make.config file in the Adaptors directory of the Wonder repository to reflect your apache installation setup.*
David Avendasora 19.1 158 1. Run make to build the Adaptor
Theodore Petrosky 59.1 159 1. Curse because of that one setting you forgot. Fix it.
David Avendasora 19.1 160 1. make clean; make
Theodore Petrosky 59.1 161 1. Install the mod_WebObjects module with apxs
David Avendasora 19.1 162 1. 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.
163 1. apachectl configtest; apachectl graceful
164 1. Test.
Theodore Petrosky 59.1 165 1. Curse again. Change the httpd.conf file as necessary.
166 1. apachectl graceful. Go to 8 as necessary.
167 1. Finally! apachectl graceful
David Avendasora 19.1 168
Theodore Petrosky 59.1 169 Enjoy your shiny new WO adaptor.
David Avendasora 19.1 170
Theodore Petrosky 59.1 171 * (((
172 Note: if you are getting the error
David Avendasora 19.1 173
Quinton Dolan 23.1 174 {{noformat}}
175 libtool: compile: unable to infer tagged configuration
176 libtool: compile: specify a tag with `--tag'
177 apxs:Error: Command failed with rc=65536
David Avendasora 19.1 178
Quinton Dolan 23.1 179 {{/noformat}}
Theodore Petrosky 59.1 180 )))
David Avendasora 19.1 181
182 Add to the end of your make.config the following:
Theodore Petrosky 59.1 183 {{code language="none"}}CC = gcc{{/code}}
karesz 60.1 184
185 == Webobjects Adaptor for Apache 2.4 ==
186
187 === Access control ===
188
189 Check out [[http:~~/~~/httpd.apache.org/docs/2.4/upgrading.html#access>>url:http://httpd.apache.org/docs/2.4/upgrading.html#access||shape="rect"]]
190
191 In 2.2, access control based on client hostname, IP address, and other characteristics of client requests was done using the directives [[Order>>url:http://httpd.apache.org/docs/2.4/mod/mod_access_compat.html#order||shape="rect"]]{{code language="none"}}{{/code}}, [[Allow>>url:http://httpd.apache.org/docs/2.4/mod/mod_access_compat.html#allow||shape="rect"]]{{code language="none"}}{{/code}}, [[Deny>>url:http://httpd.apache.org/docs/2.4/mod/mod_access_compat.html#deny||shape="rect"]]{{code language="none"}}{{/code}}, and [[Satisfy>>url:http://httpd.apache.org/docs/2.4/mod/mod_access_compat.html#satisfy||shape="rect"]]{{code language="none"}}{{/code}}.
192
193 In 2.4, such access control is done in the same way as other authorization checks, using the new module [[mod_authz_host>>url:http://httpd.apache.org/docs/2.4/mod/mod_authz_host.html||shape="rect"]]{{code language="none"}}{{/code}}. The old access control idioms should be replaced by the new authentication mechanisms, although for compatibility with old configurations, the new module [[mod_access_compat>>url:http://httpd.apache.org/docs/2.4/mod/mod_access_compat.html||shape="rect"]]{{code language="none"}}{{/code}} is provided.
194
195 ==== 2.2 configuration: ====
196
197 {{code}}
198 <Location /cgi-bin/WebObjects/>
199 Order allow,deny
200 Allow from all
201 </Location>
202 {{/code}}
203
204 ====
205 2.4 configuration: ====
206
207 {{code}}
208 <Location /cgi-bin/WebObjects/>
209 Require all granted
210 </Location>
211 {{/code}}