Changes for page Development Tools-Running Through Apache
Last modified by Aaron Rosenzweig on 2011/05/09 01:46
From version 27.1
edited by Mike Schrag
on 2007/07/23 21:42
on 2007/07/23 21:42
Change comment:
There is no comment for this version
To version 31.1
edited by Pascal Robert
on 2011/05/09 01:42
on 2011/05/09 01:42
Change comment:
There is no comment for this version
Summary
-
Page properties (3 modified, 0 added, 0 removed)
Details
- Page properties
-
- Title
-
... ... @@ -1,1 +1,1 @@ 1 - Programming__WebObjects-Development Tools-Running Through Apache1 +Development Tools-Running Through Apache - Author
-
... ... @@ -1,1 +1,1 @@ 1 -XWiki. mschrag1 +XWiki.probert - Content
-
... ... @@ -1,25 +1,37 @@ 1 -If you are accessing your application with URLs that look like http: ~/~/localhost:45437/cgi-bin/WebObjects/AppName.woa/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.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>>Development-Direct Connect]]. See that [[page>>Development-Direct Connect]] for why you don't want to be using Direct Connect. See this page for how to stop. 2 2 3 - =Turning on Apache=3 +A summary of the following steps that applies specifically to MacOS X 10.5.5 can be found here: [[Running Through Apache - Leopard & Snow Leopard Client - Summary>>Running Through Apache - Leopard & Snow Leopard Client - Summary]] 4 4 5 - Goto **System Preferences -> Sharing-> Services** and turnon**Personal Web Sharing** if it is not alreadyon.5 += Turning on Apache = 6 6 7 +Go to **System Preferences > Sharing > Services** and turn on **Personal Web Sharing** if it is not already on. You can also do it by command line with "apachectl": 8 + 9 +{{code theme="Eclipse"}} 10 +sudo apachectl restart 11 +{{/code}} 12 + 7 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 8 9 -= Restarting ApacheFix#1: Explicitly Setting Your Hostname =15 += Optional Extra Configuration: Explicitly Setting Your Hostname = 10 10 11 11 {{info title="Useful Information"}} 12 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 cause sproblems if you need to be able to access yourwebserverfrom a remote machine, including if you need to be able to test your web app from a Parallels VM.19 +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. 14 14 21 +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. 22 + 15 15 {{/info}} 16 16 17 -== Edit Apache Config 25 +== Edit Apache Config == 18 18 19 - Note: **Do NOT tryto usethe/ Rendezvous name of yourmachineinhisstep.**It will causeyou grief.Accept thisand don't even try. You havebeenwarned.27 +{{warning title="Bonjour, comment ça va? .... Trés bien, merci!"}} 20 20 21 - Edit**/etc/httpd/httpd.conf**,findthelinecontaining**ServerName**andchangeittothis:29 +*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. 22 22 31 +{{/warning}} 32 + 33 +Edit **/etc/apache2/httpd.conf**, find the line containing **ServerName** and change it to this. If you still running Tiger (OS X 10.4), the file is at **/etc/httpd/httpd.conf**. If you develop on Linux, the configuration file is probably in **/etc/httpd/conf**. 34 + 23 23 {{code}} 24 24 25 25 ServerName localhost ... ... @@ -26,16 +26,72 @@ 26 26 27 27 {{/code}} 28 28 29 -That line may be commented out by default. You can simply uncomment it (remove the leading pound sign) and t henrestartapache:41 +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 30 30 31 31 {{code}} 32 32 45 +# First, we configure the "default" to be a very restrictive set of 46 +# features. 47 +# 48 +<Directory /> 49 + Options FollowSymLinks 50 + AllowOverride None 51 + Order deny,allow 52 + Deny from all 53 +</Directory> 54 + 55 +{{/code}} 56 + 57 +And modify like so: 58 + 59 +{{code}} 60 + 61 +# First, we configure the "default" to be a very restrictive set of 62 +# features. 63 +# 64 +<Directory /> 65 + Options FollowSymLinks 66 + AllowOverride None 67 +# Order deny,allow 68 +# Deny from all 69 +</Directory> 70 + 71 +{{/code}} 72 + 73 +Got to the very end of **/etc/apache2/httpd.conf** and add : 74 + 75 +{{code}} 76 + 77 +Include /System/Library/WebObjects/Adaptors/Apache2.2/apache.conf 78 + 79 +{{/code}} 80 + 81 +{{info}} 82 +If you installed WebObjects in another directory (for instance, /Developer/WebObjects), prepend that directory path in front of /System. 83 +{{/info}} 84 + 85 +Then restart apache: 86 + 87 +{{code}} 88 + 33 33 sudo apachectl restart 34 34 35 35 {{/code}} 36 36 37 -== Tell wotaskd toUseLocalhostToo==93 +== Tell the adaptor to use localhost == 38 38 95 +Edit **/System/Library/WebObjects/Adaptors/Apache2.2/apache.conf** to make sure that your enabled/uncommented WebObjectsConfig property looks like this: 96 + 97 +{{code}} 98 + 99 +WebObjectsConfig http://localhost:1085 10 100 + 101 +{{/code}} 102 + 103 +(Note on Tiger, aka OS X 10.4.X, replace **Apache2.2** with **Apache** in the path above) 104 + 105 +== Tell wotaskd to Use Localhost Too == 106 + 39 39 Edit **/System/Library/WebObjects/JavaApplications/wotaskd.woa/Contents/Resources/Properties** 40 40 41 41 Add this line after the **WOPort=1085** one: ... ... @@ -48,91 +48,84 @@ 48 48 49 49 Now you need to restart wotaskd: 50 50 119 +===== OS X 10.5 Leopard and afterward (where launchd is used to control wotaskd) ===== 120 + 51 51 {{code}} 52 52 53 -sudo systemstarter stop "WebObjects Services" 54 -sudo systemstarter start "WebObjects Services" 123 +sudo launchctl stop com.apple.webobjects.wotaskd 55 55 56 56 {{/code}} 57 57 58 58 or 59 59 60 - restartwotaskd and womonitorwith launchctlif your WebObjectsinstalllaunchesthatway.129 +===== {{color value="#000000"}}{*}OS X Tiger 10.4 and earlier{*}{{/color}} ===== 61 61 62 -== Finally, Configure your Application == 63 - 64 -Add or edit these launch parameters: 65 - 66 66 {{code}} 67 67 68 --WODirectConnectEnabled false 69 --WOHost localhost 70 --WOAdaptorURL http://localhost/cgi-bin/WebObjects 71 --WOPort 5555 133 +sudo systemstarter stop "WebObjects Services" 134 +sudo systemstarter start "WebObjects Services" 72 72 73 73 {{/code}} 74 74 75 - The WOPort is optional, but useful if you wantconsistent URLs for bookmarks and such. Youcanuse any number you want, butit needs to be unique for eachapplication youlaunch (or rather,youcan only run one app instance on a given WOPortat a time). In WOLips, WOPort, WODirectConnectEnabled,andWOAdaptorURLalreadyexist and just need tobeupdated.WOHost does not, and needs to be added. The dashinfrontof thename ("-WOHost")is important and must be in the name forthesetting to workproperly.138 +launchd should automatically start wotaskd again for you if configured properly. 76 76 77 -You may wantto setthis in yourglobal WOLips settings so you don'thavetoset itevery time youmake anew launch configuration. You will need togobackandmodify existinglaunchconfigurations with these settings even if you set it globally.Global settings onlyapplyto newlycreated launch configurations.140 +You can check for whether wotaskd is running as a launchd job by typing 78 78 79 - = Restarting ApacheFix #2: Kickstart =142 +{{code}} 80 80 81 - Thealternative way to restart apacheisohavea scriptrun any time your network changes. It turnsout that OS X supports such a capability already via Kickstart.144 +sudo launchctl list | grep webobjects 82 82 83 - == Making a restart script ==146 +{{/code}} 84 84 85 - Create a scriptnamed/usr/local/bin/restartApache andsetthe contentsto:148 +which will give something like this: 86 86 87 87 {{code}} 88 88 89 -#!/bin/bash 90 -/usr/sbin/apachectl stop 91 -sleep 1 92 -/usr/sbin/apachectl start 152 +43 - com.apple.webobjects.wotaskd 93 93 94 94 {{/code}} 95 95 96 - ==ModifyingKicker==156 +(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"]]) 97 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: 158 +== Finally, Configure your Application == 100 100 160 +Add or edit these launch parameters: 161 + 101 101 {{code}} 102 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> 164 +-WODirectConnectEnabled false 165 +-WOHost localhost 166 +-WOAdaptorURL http://localhost/cgi-bin/WebObjects 167 +-WOPort 5555 118 118 119 119 {{/code}} 120 120 121 - ==Restart==171 +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. 122 122 123 - Restart yourmachine(you maybe able to getawaywithjustlogging out andbackin).Any networkchangeswill nowautomaticallyrestartApache.173 +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. To change the global settings, in Eclipse, open the Eclipse menu, choose Preferences... and select WOLips > Launch. 124 124 125 -= =ExtraCredit ==175 += Apache Restart = 126 126 127 - I also like to have a growlnotificationfire whenmyApacherestarts. Todothis:177 +{{info title="Why would I need this?"}} 128 128 129 - 1.grab thegrowlshellscript from http:~/~/www.macosxhints.com/dlfiles/growl_sh.txt.130 - 1.next,at the endofyour/usr/local/bin/restartApachescript,youcanadd:179 +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. 180 +If you already implemented the "localhost" explicit hostname setup above, then you will probably not need to bother with this section. 131 131 182 +No, really. Why would one need this? Is there a difference between ("apachectl stop" ; "apachectl start") and "apachectl restart"? If so, that may be a problem with apachectl. If there is a difference, why is the difference important? What bad thing will happen if one only uses "apachectl restart"? Pascal's answer: there is no difference between apachectl stop/start and apachectl restart, so the restart script could simply do a "apachectl restart". 183 + 184 +{{/info}} 185 + 186 +== Making a restart script == 187 + 188 +Create a script named /usr/local/bin/restartApache and set the contents to: 189 + 132 132 {{code}} 133 133 134 -export G_APPLICATION_ICON=EOModeler.app 135 -export G_TITLE=WebObjects 136 -/usr/local/bin/growl "Apache Restarted" 192 +#!/bin/bash 193 +/usr/sbin/apachectl stop 194 +sleep 1 195 +/usr/sbin/apachectl start 137 137 138 138 {{/code}} 198 + 199 +Please note that you DON'T need to do this if you set your ServerName in Apache to localhost. Running everything under localhost is the best way to go.