Version 54.1 by Kieran Kelleher on 2007/10/18 08:04

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