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

Hide last authors
Mike Schrag 26.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>>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.
Kieran Kelleher 22.1 2
Pascal Robert 24.1 3 = Turning on Apache =
Kieran Kelleher 22.1 4
Pascal Robert 24.1 5 Go to **System Preferences -> Sharing -> Services** and turn on **Personal Web Sharing** if it is not already on.
Kieran Kelleher 22.1 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
Pascal Robert 24.1 9 = Restarting Apache Fix #1: Explicitly Setting Your Hostname =
Kieran Kelleher 22.1 10
11 {{info title="Useful Information"}}
12
Pascal Robert 24.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), 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.
Kieran Kelleher 22.1 14
15 {{/info}}
16
Pascal Robert 24.1 17 == Edit Apache Config ==
Kieran Kelleher 22.1 18
Pascal Robert 24.1 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.
Kieran Kelleher 22.1 20
Pascal Robert 24.1 21 Edit **/etc/httpd/httpd.conf**, find the line containing **ServerName** and change it to this:
Kieran Kelleher 22.1 22
23 {{code}}
24
25 ServerName localhost
26
27 {{/code}}
28
Pascal Robert 24.1 29 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 30
31 {{code}}
32
33 sudo apachectl restart
34
35 {{/code}}
36
Pascal Robert 24.1 37 == Tell wotaskd to Use Localhost Too ==
Kieran Kelleher 22.1 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
Pascal Robert 24.1 60 restart wotaskd and womonitor with launchctl if your WebObjects install launches that way.
Kieran Kelleher 22.1 61
Pascal Robert 24.1 62 == Finally, Configure your Application ==
63
64 Add or edit these launch parameters:
65
Kieran Kelleher 22.1 66 {{code}}
67
Pascal Robert 24.1 68 -WODirectConnectEnabled false
69 -WOHost localhost
70 -WOAdaptorURL http://localhost/cgi-bin/WebObjects
71 -WOPort 5555
Kieran Kelleher 22.1 72
73 {{/code}}
74
Pascal Robert 24.1 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.
Kieran Kelleher 22.1 76
Pascal Robert 24.1 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.
Kieran Kelleher 22.1 78
Pascal Robert 24.1 79 = Restarting Apache Fix #2: Kickstart =
Kieran Kelleher 22.1 80
Pascal Robert 24.1 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.
Kieran Kelleher 22.1 82
Pascal Robert 24.1 83 == Making a restart script ==
Kieran Kelleher 22.1 84
Pascal Robert 24.1 85 Create a script named /usr/local/bin/restartApache and set the contents to:
Kieran Kelleher 22.1 86
87 {{code}}
88
Pascal Robert 24.1 89 #!/bin/bash
90 /usr/sbin/apachectl stop
91 sleep 1
92 /usr/sbin/apachectl start
Kieran Kelleher 22.1 93
94 {{/code}}
95
Pascal Robert 24.1 96 == Modifying Kicker ==
Kieran Kelleher 22.1 97
Pascal Robert 24.1 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:
Kieran Kelleher 22.1 100
101 {{code}}
102
Pascal Robert 24.1 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>
Kieran Kelleher 22.1 118
119 {{/code}}
120
Pascal Robert 24.1 121 == Restart ==
Kieran Kelleher 22.1 122
Pascal Robert 24.1 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.
Kieran Kelleher 22.1 124
Pascal Robert 24.1 125 == Extra Credit ==
Kieran Kelleher 22.1 126
Pascal Robert 24.1 127 I also like to have a growl notification fire when my Apache restarts. To do this:
Kieran Kelleher 22.1 128
Pascal Robert 24.1 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:
Kieran Kelleher 22.1 131
132 {{code}}
133
Pascal Robert 24.1 134 export G_APPLICATION_ICON=EOModeler.app
135 export G_TITLE=WebObjects
136 /usr/local/bin/growl "Apache Restarted"
Kieran Kelleher 22.1 137
138 {{/code}}