Last modified by Aaron Rosenzweig on 2011/05/09 01:46

Hide last authors
Aaron Rosenzweig 74.1 1 If you are accessing your application with URLs that look like [[http:~~/~~/localhost:45437/cgi-bin/WebObjects/AppName.woa/>>url:http://localhost:45437/cgi-bin/WebObjects/AppName.woa/||shape="rect"]] (with the xxx:portnum instead of xxxx/-portnum) ... then you are using the [[Evil Direct Connect>>doc:WO.Home.To classify.Development-Direct Connect.WebHome]]. See that [[page>>doc:WO.Home.To classify.Development-Direct Connect.WebHome]] for why you don't want to be using Direct Connect. See this page for how to stop.
Kieran Kelleher 22.1 2
Aaron Rosenzweig 75.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>>doc:documentation.Home.How-tos.Development Tools-Running Through Apache.Running Through Apache - Leopard & Snow Leopard Client - Summary.WebHome]]
Kieran Kelleher 22.1 4
Kieran Kelleher 66.1 5 = Turning on Apache =
Kieran Kelleher 28.1 6
Pascal Robert 71.1 7 Go to **System Preferences -> Sharing -> Services** and turn on **Personal Web Sharing** if it is not already on. You can also do it by command line with "apachectl":
Kieran Kelleher 66.1 8
Pascal Robert 70.1 9 {{code theme="Eclipse"}}
10 sudo apachectl restart
11 {{/code}}
12
Pascal Robert 71.1 13 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.
Kieran Kelleher 66.1 14
15 = Optional Extra Configuration: Explicitly Setting Your Hostname =
16
Mike Schrag 64.1 17 {{info title="Useful Information"}}
Pascal Robert 71.1 18 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. Pascal's note: setting ServerName to localhost won't block access from other network interfaces. The only Apache configuration that can block access from other interfaces than localhost is the Listen directive. As long as you let Apache to listen on all network interfaces, access from other machines will work.
Mike Schrag 64.1 19
Kieran Kelleher 66.1 20 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.
Mike Schrag 64.1 21 {{/info}}
22
Kieran Kelleher 66.1 23 == Edit Apache Config ==
Kieran Kelleher 22.1 24
Kieran Kelleher 66.1 25 {{warning title="Bonjour, comment ça va? .... Trés bien, merci!"}}
Pascal Robert 71.1 26 **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 66.1 27 {{/warning}}
28
Pascal Robert 71.1 29 Edit **/etc/apache2/httpd.conf**, find the line containing **ServerName** and change it to this. If you still running Tiger (OS X 10.4), the file is at **/etc/httpd/httpd.conf**. If you develop on Linux, the configuration file is probably in **/etc/httpd/conf**.
Kieran Kelleher 66.1 30
Kieran Kelleher 22.1 31 {{code}}
32
33 ServerName localhost
34
35 {{/code}}
36
Pascal Robert 71.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
Pascal Robert 70.1 41 # First, we configure the "default" to be a very restrictive set of
42 # features.
Kieran Kelleher 66.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
Pascal Robert 70.1 57 # First, we configure the "default" to be a very restrictive set of
58 # features.
Kieran Kelleher 66.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
Pascal Robert 70.1 77 {{info}}
78 If you installed WebObjects in another directory (for instance, /Developer/WebObjects), prepend that directory path in front of /System.
79 {{/info}}
80
Kieran Kelleher 66.1 81 Then restart apache:
82
83 {{code}}
84
Kieran Kelleher 22.1 85 sudo apachectl restart
86
87 {{/code}}
88
Kieran Kelleher 66.1 89 == Tell the adaptor to use localhost ==
Pascal Robert 56.1 90
Kieran Kelleher 66.1 91 Edit **/System/Library/WebObjects/Adaptors/Apache2.2/apache.conf** to make sure that your enabled/uncommented WebObjectsConfig property looks like this:
92
93 {{code}}
94
95 WebObjectsConfig http://localhost:1085 10
96
97 {{/code}}
98
99 (Note on Tiger, aka OS X 10.4.X, replace **Apache2.2** with **Apache** in the path above)
100
101 == Tell wotaskd to Use Localhost Too ==
102
Kieran Kelleher 22.1 103 Edit **/System/Library/WebObjects/JavaApplications/wotaskd.woa/Contents/Resources/Properties**
104
105 Add this line after the **WOPort=1085** one:
106
107 {{code}}
108
109 WOHost=localhost
110
111 {{/code}}
112
113 Now you need to restart wotaskd:
114
Pascal Robert 70.1 115 ===== OS X 10.5 Leopard and afterward (where launchd is used to control wotaskd) =====
Kieran Kelleher 66.1 116
Kieran Kelleher 22.1 117 {{code}}
118
Pascal Robert 70.1 119 sudo launchctl stop com.apple.webobjects.wotaskd
Ray Kiddy 30.1 120
121 {{/code}}
122
David Holt 32.1 123 or
Ray Kiddy 30.1 124
Pascal Robert 71.1 125 ===== (% style="color: rgb(0,0,0);" %)**OS X Tiger 10.4 and earlier**(%%) =====
Ray Kiddy 30.1 126
Kieran Kelleher 66.1 127 {{code}}
Pascal Robert 24.1 128
Pascal Robert 70.1 129 sudo systemstarter stop "WebObjects Services"
130 sudo systemstarter start "WebObjects Services"
Kieran Kelleher 66.1 131
132 {{/code}}
133
134 launchd should automatically start wotaskd again for you if configured properly.
135
136 You can check for whether wotaskd is running as a launchd job by typing
137
138 {{code}}
139
140 sudo launchctl list | grep webobjects
141
142 {{/code}}
143
144 which will give something like this:
145
146 {{code}}
147
Pascal Robert 68.1 148 43 - com.apple.webobjects.wotaskd
Kieran Kelleher 66.1 149
150 {{/code}}
151
Timothy Worman 73.1 152 (In 10.5 it appears to be necessary to launch with launchctl. See [[Running Monitor and wotaskd on Mac OS X 10.5 "client">>doc:WO.Home.Deprecated.WO 5\.4 Getting Started.WebHome||anchor="javamonitor"]])
Kieran Kelleher 66.1 153
154 == Finally, Configure your Application ==
155
Pascal Robert 24.1 156 Add or edit these launch parameters:
157
Kieran Kelleher 22.1 158 {{code}}
159
Pascal Robert 24.1 160 -WODirectConnectEnabled false
161 -WOHost localhost
162 -WOAdaptorURL http://localhost/cgi-bin/WebObjects
163 -WOPort 5555
Kieran Kelleher 22.1 164
165 {{/code}}
166
Pascal Robert 71.1 167 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 168
Pascal Robert 71.1 169 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. To change the global settings, in Eclipse, open the Eclipse menu, choose Preferences... and select WOLips -> Launch.
Kieran Kelleher 66.1 170
171 = Apache Restart =
172
173 {{info title="Why would I need this?"}}
174 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.
Pascal Robert 71.1 175 If you already implemented the "localhost" explicit hostname setup above, then you will probably not need to bother with this section.
Kieran Kelleher 66.1 176
Pascal Robert 70.1 177 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"? Pascal's answer: there is no difference between apachectl stop/start and apachectl restart, so the restart script could simply do a "apachectl restart".
Kieran Kelleher 66.1 178 {{/info}}
179
180 == Making a restart script ==
181
182 Create a script named /usr/local/bin/restartApache and set the contents to:
183
184 {{code}}
185
186 #!/bin/bash
187 /usr/sbin/apachectl stop
188 sleep 1
189 /usr/sbin/apachectl start
190
191 {{/code}}
Pascal Robert 70.1 192
193 Please note that you DON'T need to do this if you set your ServerName in Apache to localhost. Running everything under localhost is the best way to go.