Version 27.1 by Mike Schrag on 2007/07/23 21:42

Show last authors
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>>Programming__WebObjects-Web Applications-Development-Direct Connect]]. See that page for why you don't want to be using Direct Connect. See this page for how to stop.
2
3 = Turning on Apache =
4
5 Go to **System Preferences -> Sharing -> Services** and turn on **Personal Web Sharing** if it is not already on.
6
7 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.
8
9 = Restarting Apache Fix #1: Explicitly Setting Your Hostname =
10
11 {{info title="Useful Information"}}
12
13 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), it causes problems if you need to be able to access your webserver from a remote machine, including if you need to be able to test your web app from a Parallels VM.
14
15 {{/info}}
16
17 == Edit Apache Config ==
18
19 Note: **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.
20
21 Edit **/etc/httpd/httpd.conf**, find the line containing **ServerName** and change it to this:
22
23 {{code}}
24
25 ServerName localhost
26
27 {{/code}}
28
29 That line may be commented out by default. You can simply uncomment it (remove the leading pound sign) and then restart apache:
30
31 {{code}}
32
33 sudo apachectl restart
34
35 {{/code}}
36
37 == Tell wotaskd to Use Localhost Too ==
38
39 Edit **/System/Library/WebObjects/JavaApplications/wotaskd.woa/Contents/Resources/Properties**
40
41 Add this line after the **WOPort=1085** one:
42
43 {{code}}
44
45 WOHost=localhost
46
47 {{/code}}
48
49 Now you need to restart wotaskd:
50
51 {{code}}
52
53 sudo systemstarter stop "WebObjects Services"
54 sudo systemstarter start "WebObjects Services"
55
56 {{/code}}
57
58 or
59
60 restart wotaskd and womonitor with launchctl if your WebObjects install launches that way.
61
62 == Finally, Configure your Application ==
63
64 Add or edit these launch parameters:
65
66 {{code}}
67
68 -WODirectConnectEnabled false
69 -WOHost localhost
70 -WOAdaptorURL http://localhost/cgi-bin/WebObjects
71 -WOPort 5555
72
73 {{/code}}
74
75 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.
76
77 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.
78
79 = Restarting Apache Fix #2: Kickstart =
80
81 The alternative way to restart apache is to have a script run any time your network changes. It turns out that OS X supports such a capability already via Kickstart.
82
83 == Making a restart script ==
84
85 Create a script named /usr/local/bin/restartApache and set the contents to:
86
87 {{code}}
88
89 #!/bin/bash
90 /usr/sbin/apachectl stop
91 sleep 1
92 /usr/sbin/apachectl start
93
94 {{/code}}
95
96 == Modifying Kicker ==
97
98 1. Edit /System/Library/SystemConfiguration/Kicker.bundle/Contents/Resources/Kicker.xml
99 1. At the end of the <array> section, add the following block of XML:
100
101 {{code}}
102
103 <dict>
104 <key>execCommand</key>
105 <string>/usr/local/bin/restartApache</string>
106 <key>execUID</key>
107 <integer>0</integer>
108 <key>keys</key>
109 <array>
110 <string>State:/Network/Global/DNS</string>
111 <string>State:/Network/Global/IPv4</string>
112 <string>State:/Network/Global/IPv6</string>
113 <string>State:/Network/Global/NetInfo</string>
114 </array>
115 <key>name</key>
116 <string>restart_apache</string>
117 </dict>
118
119 {{/code}}
120
121 == Restart ==
122
123 Restart your machine (you may be able to get away with just logging out and back in). Any network changes will now automatically restart Apache.
124
125 == Extra Credit ==
126
127 I also like to have a growl notification fire when my Apache restarts. To do this:
128
129 1. grab the growl shell script from http:~/~/www.macosxhints.com/dlfiles/growl_sh.txt.
130 1. next, at the end of your /usr/local/bin/restartApache script, you can add:
131
132 {{code}}
133
134 export G_APPLICATION_ICON=EOModeler.app
135 export G_TITLE=WebObjects
136 /usr/local/bin/growl "Apache Restarted"
137
138 {{/code}}