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

From version 20.1
edited by David Avendasora
on 2010/12/03 11:05
Change comment: There is no comment for this version
To version 21.1
edited by smmccraw
on 2007/07/08 09:45
Change comment: There is no comment for this version

Summary

Details

Page properties
Title
... ... @@ -1,1 +1,1 @@
1 -Configuring Apache for WebObjects
1 +Programming__WebObjects-Web Applications-Deployment-Apache
Author
... ... @@ -1,1 +1,1 @@
1 -XWiki.avendasora
1 +XWiki.smmccraw
Content
... ... @@ -1,109 +1,103 @@
1 -== Overview ==
1 +== Overview ==
2 2  
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>>Development-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.
3 +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>>Programming__WebObjects-Web Applications-Development-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.
4 4  
5 -== Split Install ==
5 +== Split Install ==
6 6  
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, ##/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.
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, /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.
8 8  
9 -== mod//expires// ==
9 +== mod//expires // ==
10 10  
11 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.//
12 12  
13 13  An example mod//expires configuration might look like~://
14 14  
15 -{{code value="xml"}}
15 +{{panel}}
16 16  
17 -<IfModule mod_expires.c>
18 - ExpiresActive On
19 - ExpiresDefault A60
20 - ExpiresByType image/bmp A3600
21 - ExpiresByType image/gif A3600
22 - ExpiresByType image/ief A3600
23 - ExpiresByType image/jpeg A3600
24 - ExpiresByType image/png A3600
25 -</IfModule>
17 + <IfModule mod_expires.c>
18 + ExpiresActive On
19 + ExpiresDefault A60
20 + ExpiresByType image/bmp A3600
21 + ExpiresByType image/gif A3600
22 + ExpiresByType image/ief A3600
23 + ExpiresByType image/jpeg A3600
24 + ExpiresByType image/png A3600
25 + </IfModule>
26 26  
27 -{{/code}}
27 +{{/panel}}
28 28  
29 29  You will also need the corresponding type-extension mappings:
30 30  
31 -{{code value="xml"}}
31 +{{panel}}
32 32  
33 -<IfModule mod_mime.c>
34 - AddType image/bmp bmp
35 - AddType image/gif gif
36 - AddType image/ief ief
37 - AddType image/jpeg jpeg
38 - AddType image/jpeg jpg
39 - AddType image/jpeg jpe
40 - ...
41 -</IfModule>
33 + <IfModule mod_mime.c>
34 + AddType image/bmp bmp
35 + AddType image/gif gif
36 + AddType image/ief ief
37 + AddType image/jpeg jpeg
38 + AddType image/jpeg jpg
39 + AddType image/jpeg jpe
40 + ...
41 + </IfModule>
42 42  
43 -{{/code}}
43 +{{/panel}}
44 44  
45 45  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).
46 46  
47 -== mod//rewrite// ==
47 +== mod//rewrite // ==
48 48  
49 -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 "mod//rewrite" that allows you to rewrite the URL requests of your site based on a series of regular expressions and rules.//
49 +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 "mod//rewrite" that allows you to rewrite the URL requests of your site based on a series of regular expressions and rules.//
50 50  
51 -Aaron Rosenzweig has a very thorough article about [[using mod//rewrite with Apache//>>http://www.jewelryluv.com/fashion/pageWithName/ModRewrite/]].
51 +Aaron Rosenzweig has a very thorough article about [[using mod//rewrite with Apache//>>http://www.jewelryluv.com/fashion/pageWithName/ModRewrite]].
52 52  
53 -=== mod//rewrite with mod//webobjects ===
53 +=== mod//rewite with mod//webobjects ===
54 54  
55 55  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).//
56 56  
57 57  So in http.conf, search for mod//rewrite and change it to~://
58 58  
59 -{{noformat}}
59 +{{panel}}
60 60  
61 -LoadModule WebObjects_module /System/Library/WebObjects/Adaptors/Apache/mod_WebObjects.so
62 -LoadModule rewrite_module libexec/httpd/mod_rewrite.so
61 + LoadModule WebObjects_module /System/Library/WebObjects/Adaptors/Apache/mod_WebObjects.so
62 + LoadModule rewrite_module libexec/httpd/mod_rewrite.so
63 63  
64 -{{/noformat}}
64 +{{/panel}}
65 65  
66 66  , find again:
67 67  
68 -{{noformat}}
68 +{{panel}}
69 69  
70 -AddModule mod_WebObjects.c
71 -AddModule mod_rewrite.c
70 + AddModule mod_WebObjects.c
71 + AddModule mod_rewrite.c
72 72  
73 -{{/noformat}}
73 +{{/panel}}
74 74  
75 -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.
75 +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.
76 76  
77 -=== Mike Schrag ===
77 +=== Mike Schrag ===
78 78  
79 79  Here's an example mod//rewrite we use on one of our apps~://
80 80  
81 -{{code value="xml"}}
81 +{{panel}}
82 82  
83 -<IfModule mod_rewrite.c>
84 - RewriteEngine On
85 - RewriteRule ^/$ /page/HomePage [R]
86 - RewriteCond %{QUERY_STRING} ^appNum=([-0-9]+)(.*)$
87 - RewriteRule ^/page/(.*)$ /cgi-bin/WebObjects/AppName.woa/%1/wa/viewPage?pageName=$1%2 [L,PT]
88 - RewriteRule ^/page/(.*)$ /cgi-bin/WebObjects/AppName.woa/wa/viewPage?pageName=$1 [L,PT,QSA]
89 -</IfModule>
83 + <IfModule mod_rewrite.c>
84 + RewriteEngine On
85 + RewriteRule ^/$ /page/HomePage [R]
86 + RewriteCond %{QUERY_STRING} ^appNum=([-0-9]+)(.*)$
87 + RewriteRule ^/page/(.*)$ /cgi-bin/WebObjects/AppName.woa/%1/wa/viewPage?pageName=$1%2 [L,PT]
88 + RewriteRule ^/page/(.*)$ /cgi-bin/WebObjects/AppName.woa/wa/viewPage?pageName=$1 [L,PT,QSA]
89 + </IfModule>
90 90  
91 -{{/code}}
91 +{{/panel}}
92 92  
93 -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]]##.
93 +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.
94 94  
95 -{{id value="Apache22Adapter"}}{{/id}}
95 +== WebObjects Adaptor for Apache 2.2 ==
96 96  
97 -=== Jeff Schmitz ===
97 +=== Travis Cripps ===
98 98  
99 -This one stumped me for a couple days, so thought I'd add it. &nbsp;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. &nbsp;However, on the deployment machine I also had to add them to the /etc/apache2/sites/0000//any//.conf file. &nbsp;//
99 +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.
100 100  
101 -== WebObjects Adaptor for Apache 2.2 ==
102 -
103 -=== Travis Cripps ===
104 -
105 -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>>http://webobjects.mdimension.com/wonder/mod_WebObjects/]] for various OS available)
106 -
107 107  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.//
108 108  
109 109  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.
... ... @@ -112,32 +112,21 @@
112 112  
113 113  The new default configuration is:
114 114  
115 -{{code value="xml"}}
109 +{{panel}}
116 116  
117 -<Directory />
118 - Options FollowSymLinks
119 - AllowOverride None
120 - Order deny,allow
121 - Deny from all
122 -</Directory>
111 + <Directory />
112 + Options FollowSymLinks
113 + AllowOverride None
114 + Order deny,allow
115 + Deny from all
116 + </Directory>
123 123  
124 -{{/code}}
118 +{{/panel}}
125 125  
126 126  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.
127 127  
128 128  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.
129 129  
130 -{{info title="Note"}}
131 -
132 -The default {{ScriptAlias}} directive in the 10.5 and 10.6 {{httpd.conf}} files is:
133 -\\
134 -{noformat}
135 -ScriptAliasMatch ^/cgi-bin/((?!(?i:webobjects)).*$) "/Library/WebServer/CGI-Executables/$1"
136 -{noformat}
137 -This prevents {{/cgi-bin/WebObjects}} from matching, so no change to {{WebObjectsAlias}} or {{ScriptAlias}} is necessary.
138 -
139 -{{/info}}
140 -
141 141  Other than these tips, it's pretty much the standard compilation and installation, and configuration.
142 142  
143 143  1. Alter the make.config file in the Adaptors directory of the Wonder repository to reflect your apache installation setup.
... ... @@ -150,19 +150,21 @@
150 150  1. Test.
151 151  1. Curse again. Change the httpd.conf file as necessary.
152 152  1. apachectl graceful. Go to 8 as necessary.
153 -1. Finally apachectl graceful
136 +1. Finally! apachectl graceful
154 154  
155 -Enjoy your shiny new WO adaptor. :-)
138 +Enjoy your shiny new WO adaptor. :)
156 156  
157 157  * Note: if you are getting the error
158 158  
159 -{{noformat}}
142 +{{panel}}
160 160  
161 -libtool: compile: unable to infer tagged configuration
162 -libtool: compile: specify a tag with `--tag'
163 -apxs:Error: Command failed with rc=65536
144 + libtool: compile: unable to infer tagged configuration
145 + libtool: compile: specify a tag with `--tag'
146 + apxs:Error: Command failed with rc=65536
164 164  
165 -{{/noformat}}
148 +{{/panel}}
166 166  
167 167  Add to the end of your make.config the following:
168 -##CC = gcc##
151 +CC = gcc
152 +
153 +Category:WebObjects