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

From version 28.1
edited by Kieran Kelleher
on 2008/11/23 19:29
Change comment: There is no comment for this version
To version 24.1
edited by Pascal Robert
on 2007/09/03 17:00
Change comment: There is no comment for this version

Summary

Details

Page properties
Title
... ... @@ -1,1 +1,1 @@
1 -Development Tools-Running Through Apache
1 +Programming__WebObjects-Development Tools-Running Through Apache
Author
... ... @@ -1,1 +1,1 @@
1 -XWiki.kieran
1 +XWiki.probert
Content
... ... @@ -1,33 +1,25 @@
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.
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 for why you don't want to be using Direct Connect. See this page for how to stop.
2 2  
3 -A summary of the following steps that applies specifically to MacOS X 10.5.5 can be found here: [[Running Through Apache - Leopard Client 10.5.5 - Summary]]
3 += Turning on Apache =
4 4  
5 -= Turning on Apache =
5 +Go to **System Preferences -> Sharing -> Services** and turn on **Personal Web Sharing** if it is not already on.
6 6  
7 -Go to **System Preferences > Sharing > Services** and turn on **Personal Web Sharing** if it is not already on.
8 -
9 9  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.
10 10  
11 -= Optional Extra Configuration: Explicitly Setting Your Hostname =
9 += Restarting Apache Fix #1: Explicitly Setting Your Hostname =
12 12  
13 13  {{info title="Useful Information"}}
14 14  
15 -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.
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.
16 16  
17 -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.
18 -
19 19  {{/info}}
20 20  
21 -== Edit Apache Config ==
17 +== Edit Apache Config ==
22 22  
23 -{{warning title="Bonjour, comment ça va? .... Trés bien, merci!"}}
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.
24 24  
25 -*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.
21 +Edit **/etc/httpd/httpd.conf**, find the line containing **ServerName** and change it to this:
26 26  
27 -{{/warning}}
28 -
29 -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**.
30 -
31 31  {{code}}
32 32  
33 33  ServerName localhost
... ... @@ -34,68 +34,16 @@
34 34  
35 35  {{/code}}
36 36  
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
29 +That line may be commented out by default. You can simply uncomment it (remove the leading pound sign) and then restart apache:
38 38  
39 39  {{code}}
40 40  
41 -# First, we configure the "default" to be a very restrictive set of
42 -# features.
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 -
57 -# First, we configure the "default" to be a very restrictive set of
58 -# features.
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 -
77 -Then restart apache:
78 -
79 -{{code}}
80 -
81 81  sudo apachectl restart
82 82  
83 83  {{/code}}
84 84  
85 -== Tell the adaptor to use localhost ==
37 +== Tell wotaskd to Use Localhost Too ==
86 86  
87 -Edit **/System/Library/WebObjects/Adaptors/Apache2.2/apache.conf** to make sure that your enabled/uncommented WebObjectsConfig property looks like this:
88 -
89 -{{code}}
90 -
91 -WebObjectsConfig http://localhost:1085 10
92 -
93 -{{/code}}
94 -
95 -(Note on Tiger, aka OS X 10.4.X, replace **Apache2.2** with **Apache** in the path above)
96 -
97 -== Tell wotaskd to Use Localhost Too ==
98 -
99 99  Edit **/System/Library/WebObjects/JavaApplications/wotaskd.woa/Contents/Resources/Properties**
100 100  
101 101  Add this line after the **WOPort=1085** one:
... ... @@ -118,9 +118,8 @@
118 118  or
119 119  
120 120  restart wotaskd and womonitor with launchctl if your WebObjects install launches that way.
121 -(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"]]
122 122  
123 -== Finally, Configure your Application ==
62 +== Finally, Configure your Application ==
124 124  
125 125  Add or edit these launch parameters:
126 126  
... ... @@ -137,15 +137,10 @@
137 137  
138 138  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.
139 139  
140 -= Apache Restart =
79 += Restarting Apache Fix #2: Kickstart =
141 141  
142 -{{info title="Why would I need this?"}}
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.
143 143  
144 -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.
145 -If you already implemented the "localhost" explicit hostname setup above, then you will probably not need to bother with this section.
146 -
147 -{{/info}}
148 -
149 149  == Making a restart script ==
150 150  
151 151  Create a script named /usr/local/bin/restartApache and set the contents to:
... ... @@ -158,3 +158,47 @@
158 158  /usr/sbin/apachectl start
159 159  
160 160  {{/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}}