Macports, Apache PATH evn?

Ryan Schmidt ryandesign at
Fri May 14 16:34:50 PDT 2010

On May 14, 2010, at 18:11, Joel Taylor wrote:

> Hi, I need to update my Macports Apache PATH environment variable.
> I've tried a ton of different ways for my system (OS X 10.6) .profile, /etc/profile, /etc/paths, /etc/paths.d/ etc etc 
> But nothing seems to path the new paths to Apache.
> I'm testing with a PHP script like this:
> $hey = shell_exec('echo $PATH'." 2>&1"); var_dump($hey); echo getenv('PATH');
> And it's returning:  string '/usr/bin:/bin:/usr/sbin:/sbin
> ' (length=30)
> Can someone help me add to my system (or apache) the PATH to Macports mysql, so I can use "shell_exec" in PHP?

For apache questions you might have better luck getting an answer in an apache support venue.

It looks like one bad option is to edit the apache launchd plist:

For the MacPorts apache, you would use /Library/LaunchDaemons/org.macports.apache2.plist instead of the /System/Library/LaunchDaemons/org.apache.httpd.plist mentioned in the article. I'm not thrilled with this method because the edits you make to these files will disappear next time you upgrade apache.

I believe the correct way to do what you want is to edit /opt/local/bin/env-vars. Note however that this file too will be overwritten when you upgrade apache and your changes will be lost. In this case, however, this is a bug; the port should be fixed to not do that:

Until that bug is fixed, make sure you keep a copy of your modified env-vars (e.g. call it "env-vars.mine") so that if an apache upgrade wipes out your changes in env-vars, you can easily copy env-vars.mine back on top of env-vars to restore your changes.

More information about the macports-users mailing list