Version 30.1 by Ray Kiddy on 2011/01/13 17:04

Hide last authors
Ray Kiddy 30.1 1 If you are accessing your application with URLs that look like [[http://localhost:45437/cgi-bin/WebObjects/AppName.woa/]] (with the xxx:portnum instead of xxxx/-portnum) ... then you are using the [[Evil Direct Connect>>Development-Direct Connect]]. See that [[page>>Development-Direct Connect]] for why you don't want to be using Direct Connect. See this page for how to stop.
Kieran Kelleher 22.1 2
Ray Kiddy 30.1 3 A summary of the following steps that applies specifically to MacOS X 10.5.5 can be found here: [[Running Through Apache - Leopard & Snow Leopard Client - Summary>>Running Through Apache - Leopard & Snow Leopard Client - Summary]]
Kieran Kelleher 22.1 4
Kieran Kelleher 28.1 5 = Turning on Apache =
Kieran Kelleher 22.1 6
Kieran Kelleher 28.1 7 Go to **System Preferences > Sharing > Services** and turn on **Personal Web Sharing** if it is not already on.
8
Kieran Kelleher 22.1 9 When you turn on your web server, Apache will listen on the network interfaces that were configured when it starts. If you change networks, you may need to manually restart apache. You can do this by either stopping and restarting Personal Web Sharing, or you can run "apachectl restart" from the commandline as the root user. Because this can get annoying if you are working on a laptop, or periodically using VPN's, there are a couple ways to make this process easier.
10
Kieran Kelleher 28.1 11 = Optional Extra Configuration: Explicitly Setting Your Hostname =
Kieran Kelleher 22.1 12
13 {{info title="Useful Information"}}
14
Kieran Kelleher 28.1 15 The changes in this section are only required if you want your hostname to be stable across network changes. While this simplifies many aspects of development (like testing cookies and https), it may cause problems with those specific aspects (cookies, https, etc.) if you need to be able to access your dev machine from a remote machine, including if you need to be able to test your web app from a Parallels VM.
Kieran Kelleher 22.1 16
Kieran Kelleher 28.1 17 Bonjour Delays: Apparently the procedure here is also useful for preventing "Bonjour" delays when you launch the browser to test your app on your development machine.
18
Kieran Kelleher 22.1 19 {{/info}}
20
Kieran Kelleher 28.1 21 == Edit Apache Config ==
Kieran Kelleher 22.1 22
Kieran Kelleher 28.1 23 {{warning title="Bonjour, comment ça va? .... Trés bien, merci!"}}
Kieran Kelleher 22.1 24
Kieran Kelleher 28.1 25 *Do NOT try to use the Bonjour / Rendezvous name of your machine in this step.* It will cause you grief. Accept this and don't even try. You have been warned.
Kieran Kelleher 22.1 26
Kieran Kelleher 28.1 27 {{/warning}}
28
29 Edit **/etc/httpd/httpd.conf**, find the line containing **ServerName** and change it to this. If you use Leopard (OS X 10.5), the file is at **/etc/apache2/httpd.conf**.
30
Kieran Kelleher 22.1 31 {{code}}
32
33 ServerName localhost
34
35 {{/code}}
36
Kieran Kelleher 28.1 37 That line may be commented out by default. You can simply uncomment it (remove the leading pound sign). You will also need to find this block
Kieran Kelleher 22.1 38
39 {{code}}
40
Ray Kiddy 30.1 41 # First, we configure the "default" to be a very restrictive set of
42 # features.
Kieran Kelleher 28.1 43 #
44 <Directory />
45 Options FollowSymLinks
46 AllowOverride None
47 Order deny,allow
48 Deny from all
49 </Directory>
50
51 {{/code}}
52
53 And modify like so:
54
55 {{code}}
56
Ray Kiddy 30.1 57 # First, we configure the "default" to be a very restrictive set of
58 # features.
Kieran Kelleher 28.1 59 #
60 <Directory />
61 Options FollowSymLinks
62 AllowOverride None
63 # Order deny,allow
64 # Deny from all
65 </Directory>
66
67 {{/code}}
68
69 Got to the very end of **/etc/apache2/httpd.conf** and add :
70
71 {{code}}
72
73 Include /System/Library/WebObjects/Adaptors/Apache2.2/apache.conf
74
75 {{/code}}
76
77 Then restart apache:
78
79 {{code}}
80
Kieran Kelleher 22.1 81 sudo apachectl restart
82
83 {{/code}}
84
Kieran Kelleher 28.1 85 == Tell the adaptor to use localhost ==
Kieran Kelleher 22.1 86
Kieran Kelleher 28.1 87 Edit **/System/Library/WebObjects/Adaptors/Apache2.2/apache.conf** to make sure that your enabled/uncommented WebObjectsConfig property looks like this:
88
89 {{code}}
90
91 WebObjectsConfig http://localhost:1085 10
92
93 {{/code}}
94
95 (Note on Tiger, aka OS X 10.4.X, replace **Apache2.2** with **Apache** in the path above)
96
97 == Tell wotaskd to Use Localhost Too ==
98
Kieran Kelleher 22.1 99 Edit **/System/Library/WebObjects/JavaApplications/wotaskd.woa/Contents/Resources/Properties**
100
101 Add this line after the **WOPort=1085** one:
102
103 {{code}}
104
105 WOHost=localhost
106
107 {{/code}}
108
109 Now you need to restart wotaskd:
110
Ray Kiddy 30.1 111 ===== OS X Tiger 10.4 =====
112
Kieran Kelleher 22.1 113 {{code}}
114
115 sudo systemstarter stop "WebObjects Services"
116 sudo systemstarter start "WebObjects Services"
117
118 {{/code}}
119
120 or
121
Ray Kiddy 30.1 122 ===== OS X 10.5 Leopard (where launchd is used to control wotaskd) =====
123
124 {{code}}
125
126 sudo launchctl stop com.apple.webobjects.wotaskd
127
128 {{/code}}
129
130 launchd should automatically start wotaskd again for you if configured properly.
131
132 You can check for whether wotaskd is running as a launchd job by typing
133
134 {{code}}
135
136 sudo launchctl list | grep webobjects
137
138 {{/code}}
139
140 which will give something like this:
141
142 {{code}}
143
144 43 - com.apple.webobjects.wotaskd
145
146 {{/code}}
147
Kieran Kelleher 28.1 148 (In 10.5 it appears to be necessary to launch with launchctl. See [[Running Monitor and wotaskd on Mac OS X 10.5 "client">>WO 5.4 Getting Started||anchor="javamonitor"]]
Kieran Kelleher 22.1 149
Kieran Kelleher 28.1 150 == Finally, Configure your Application ==
Pascal Robert 24.1 151
152 Add or edit these launch parameters:
153
Kieran Kelleher 22.1 154 {{code}}
155
Pascal Robert 24.1 156 -WODirectConnectEnabled false
157 -WOHost localhost
158 -WOAdaptorURL http://localhost/cgi-bin/WebObjects
159 -WOPort 5555
Kieran Kelleher 22.1 160
161 {{/code}}
162
Pascal Robert 24.1 163 The WOPort is optional, but useful if you want consistent URLs for bookmarks and such. You can use any number you want, but it needs to be unique for each application you launch (or rather, you can only run one app instance on a given WOPort at a time). In WOLips, WOPort, WODirectConnectEnabled, and WOAdaptorURL already exist and just need to be updated. WOHost does not, and needs to be added. The dash in front of the name ("-WOHost") is important and must be in the name for the setting to work properly.
Kieran Kelleher 22.1 164
Pascal Robert 24.1 165 You may want to set this in your global WOLips settings so you don't have to set it every time you make a new launch configuration. You will need to go back and modify existing launch configurations with these settings even if you set it globally. Global settings only apply to newly created launch configurations.
Kieran Kelleher 22.1 166
Kieran Kelleher 28.1 167 = Apache Restart =
Kieran Kelleher 22.1 168
Kieran Kelleher 28.1 169 {{info title="Why would I need this?"}}
Kieran Kelleher 22.1 170
Kieran Kelleher 28.1 171 If you have a laptop and you get an "Application cannot be found" or some such error in the browser after auto-switching networks (for example going from a work network to a home network), restarting apache can resolve the error condition most of the time. A script is shown below to do that.
172 If you already implemented the "localhost" explicit hostname setup above, then you will probably not need to bother with this section.
173
Ray Kiddy 30.1 174 No, really. Why would one need this? Is there a difference between ("apachectl stop" ; "apachectl start") and "apachectl restart"? If so, that may be a problem with apachectl. If there is a difference, why is the difference important? What bad thing will happen if one only uses "apachectl restart"?
175
176
Kieran Kelleher 28.1 177 {{/info}}
178
Pascal Robert 24.1 179 == Making a restart script ==
Kieran Kelleher 22.1 180
Pascal Robert 24.1 181 Create a script named /usr/local/bin/restartApache and set the contents to:
Kieran Kelleher 22.1 182
183 {{code}}
184
Pascal Robert 24.1 185 #!/bin/bash
186 /usr/sbin/apachectl stop
187 sleep 1
188 /usr/sbin/apachectl start
Kieran Kelleher 22.1 189
190 {{/code}}