Version 33.1 by David Holt on 2008/10/29 12:33

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 28.1 9 = Optional Extra Configuration: Explicitly Setting Your Hostname =
Kieran Kelleher 22.1 10
11 {{info title="Useful Information"}}
12
Kieran Kelleher 28.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 28.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
Kieran Kelleher 22.1 17 {{/info}}
18
Kieran Kelleher 28.1 19 == Edit Apache Config ==
Kieran Kelleher 22.1 20
Kieran Kelleher 28.1 21 {{warning title="Bonjour, comment ça va? .... Trés bien, merci!"}}
Kieran Kelleher 22.1 22
Kieran Kelleher 28.1 23 *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 24
Kieran Kelleher 28.1 25 {{/warning}}
26
David Holt 32.1 27 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**.
Kieran Kelleher 28.1 28
Kieran Kelleher 22.1 29 {{code}}
30
31 ServerName localhost
32
33 {{/code}}
34
Kieran Kelleher 28.1 35 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 36
37 {{code}}
38
David Holt 32.1 39 # First, we configure the "default" to be a very restrictive set of
40 # features.
Kieran Kelleher 28.1 41 #
42 <Directory />
43 Options FollowSymLinks
44 AllowOverride None
45 Order deny,allow
46 Deny from all
47 </Directory>
48
49 {{/code}}
50
51 And modify like so:
52
53 {{code}}
54
David Holt 32.1 55 # First, we configure the "default" to be a very restrictive set of
56 # features.
Kieran Kelleher 28.1 57 #
58 <Directory />
59 Options FollowSymLinks
60 AllowOverride None
61 # Order deny,allow
62 # Deny from all
63 </Directory>
64
65 {{/code}}
66
67 Got to the very end of **/etc/apache2/httpd.conf** and add :
68
69 {{code}}
70
71 Include /System/Library/WebObjects/Adaptors/Apache2.2/apache.conf
72
73 {{/code}}
74
75 Then restart apache:
76
77 {{code}}
78
Kieran Kelleher 22.1 79 sudo apachectl restart
80
81 {{/code}}
82
Kieran Kelleher 28.1 83 == Tell the adaptor to use localhost ==
Kieran Kelleher 22.1 84
David Holt 32.1 85 Edit **/System/Library/WebObjects/Adaptors/Apache/apache.conf** to make sure that your enabled/uncommented WebObjectsConfig property looks like this:
Kieran Kelleher 28.1 86
87 {{code}}
88
89 WebObjectsConfig http://localhost:1085 10
90
91 {{/code}}
92
93 == Tell wotaskd to Use Localhost Too ==
94
Kieran Kelleher 22.1 95 Edit **/System/Library/WebObjects/JavaApplications/wotaskd.woa/Contents/Resources/Properties**
96
97 Add this line after the **WOPort=1085** one:
98
99 {{code}}
100
101 WOHost=localhost
102
103 {{/code}}
104
105 Now you need to restart wotaskd:
106
107 {{code}}
108
Pascal Robert 31.1 109 sudo systemstarter stop "WebObjects Services"
110 sudo systemstarter start "WebObjects Services"
Ray Kiddy 30.1 111
112 {{/code}}
113
David Holt 32.1 114 or
Ray Kiddy 30.1 115
David Holt 32.1 116 restart wotaskd and womonitor with launchctl if your WebObjects install launches that way.
117 (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"]]
Ray Kiddy 30.1 118
Kieran Kelleher 28.1 119 == Finally, Configure your Application ==
Pascal Robert 24.1 120
121 Add or edit these launch parameters:
122
Kieran Kelleher 22.1 123 {{code}}
124
Pascal Robert 24.1 125 -WODirectConnectEnabled false
126 -WOHost localhost
127 -WOAdaptorURL http://localhost/cgi-bin/WebObjects
128 -WOPort 5555
Kieran Kelleher 22.1 129
130 {{/code}}
131
Pascal Robert 24.1 132 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 133
David Holt 32.1 134 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 135
Kieran Kelleher 28.1 136 = Apache Restart =
Kieran Kelleher 22.1 137
Kieran Kelleher 28.1 138 {{info title="Why would I need this?"}}
Kieran Kelleher 22.1 139
Kieran Kelleher 28.1 140 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.
141 If you already implemented the "localhost" explicit hostname setup above, then you will probably not need to bother with this section.
142
143 {{/info}}
144
Pascal Robert 24.1 145 == Making a restart script ==
Kieran Kelleher 22.1 146
Pascal Robert 24.1 147 Create a script named /usr/local/bin/restartApache and set the contents to:
Kieran Kelleher 22.1 148
149 {{code}}
150
Pascal Robert 24.1 151 #!/bin/bash
152 /usr/sbin/apachectl stop
153 sleep 1
154 /usr/sbin/apachectl start
Kieran Kelleher 22.1 155
156 {{/code}}