0

I am in the process of trying to get a PHP PDO MySQL driver up and running under Leopard and I am basically following ideas from Tom Gidden in forcing Apache to run as i386 instead of the Leopard default of x86_64.

As per Tom's ideas I have copied

/System/Library/LaunchDaemons/org.apache.httpd.plist

to

/Library/LaunchDaemons/org.apache.httpd.plist 

And added a flag run Apache in 32 bit mode:

<string>arch</string>
<string>-i386</string>
<string>/usr/sbin/httpd</string>
<string>-D</string>
<string>FOREGROUND</string>

I have also confirmed from the Arch documentation that /Library/LaunchDemons should be processed before /System/Library/LaunchDaemons

When I reboot my mac and check the process by the Activity Monitor, the httpd process is flagged as "intel" - which is what I expect to see.

However if I open up the System Preferences->Sharing and restart Apache by Unchecking and rechecking the "Web Sharing" option, Apache starts up in 64 bit mode (as seen in Activity Monitor as an "Intel (64 bit)" process. This is not what I expected to see!

So my question are:

  • Why am I seeing that starting Apache via the System Preferences result in different behaviour than via a reboot?

  • Should I remove/rename the /System/Library/LaunchDaemons/org.apache.httpd.plist file, or is there a better way of doing things?

  • Or am I just doing things in a plain crazy manner?

Thanks for your help.

Anyone??

2 Answers 2

1

If you are looking to do things outside of the Apple setup and want consistent control, consider using Macports. It will allow you to have complete control over what version of Apache, MySQL and PHP you are using, etc.

One issue with relying on Apple's kit of Apache+PHP is that they can and will update it in a Software Update w/o much warning. And that can leave your your AMP stack broken :(

1
  • This isn't an issue about trying to do things outside of the Apple setup, but trying to understand why Apples published behaviour with regards to LaunchDemons seems to be inconsistent.
    – Peter M
    Dec 3, 2009 at 13:04
1

I believe that you can verify the parameters actually passed to the application by running:

ps auxw | grep http

I know when I'm mucking with services, I really like to use Lingon (even though it is no longer actively developed.) It gives a good idea of which tasks are scheduled, it can help for checking that your task set to be active or not, and I believe it'll check the consistency of your plist file (although, since you started from an existing one, it is likely to be good), and it is really nice for editing a launchd plist file. Be sure to look at the expert mode, especially for looking at an existing file, and note that under the help menu, you can access all relevant man pages.

You may want to change the name of your service in the plist configuration file. To check if it is available and on, you can do the following:

service --test-if-available org.apache.httpd && echo "Available" || echo "Not available"
service --test-if-configured-on org.apache.httpd && echo "On" || echo "Off"

[but replace 'org.apache.httpd' in the command with whatever you've configured it to be. Note that you can run

service --list

to see a list of all services, but unfortunately, the data does not go to stdout, and you can't pipe it.]

Another useful tool to help you figure this out is launchctl.

To see which tasks are scheduled, you can run:

launchctl list

Note that you get different results if you do it as a user than if you do it as root. I believe that root sees the tasks that are scheduled from /System/Library/LaunchDaemons and LaunchAgents, and that the user sees ones scheduled from /Library/LaunchDaemons and LaunchAgents.

Launchctl will also let you schedule/unschedule tasks. Note that in the configuration files, there is a key that states if the job is disabled. You can edit the file, or, when using the launchctl load or unload command, you can make use of the -W flag to override the current setting and write it back to disk.

The site you referenced listed the commands to unschedule the original task and schedule in your replacement as:

sudo launchctl unload /System/Library/LaunchDaemons/org.apache.httpd.plist
sudo launchctl load /Library/LaunchDaemons/org.apache.httpd.plist

which sure looks right (although I'm unsure if sudo is required for the second one).


Why does apache start up differently from System Preferences? I have two guesses.

  1. It uses /System/Library/LaunchDaemons (and if you backed this up and overrode it, you'd get the results you seek)
  2. It starts apache directly and does not use launchctl.

I opened Console while toggling the switch. It didn't show anything in system.log. In /var/log/apache2/error.log, it did show that the application was shut down and started up, but I don't know if it was direct or not.


I think what I would do is:

  • Remove the /Library/LaunchDaemons/org.apache.httpd.plist
  • Back up /System/Library/LaunchDaemons/org.apache.httpd.plist, perhaps to another folder
  • Edit it (and I would probably use Lingon) to start apache in 32 bit mode
  • See if it works when rebooting/reloading the task
  • See if it works when turning web sharing on or off
  • If it does work, back up your modified version of the file, too (just in case an OS update stomps on it).

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .