8
OCT
23:42

Apache2, PHP5 and environment variables in OSX

Ok. So I’ve been sitting here with this problem for the last four hours. And finally I found the solution with the help of Jim the Jimbo. Anyway. I’ve been trying to get ImageMagick to work on my OSX/Apache2/PHP-thingy. But I could not figure out how to pass on the PATH variable I added. After a couple of hours Jim found this here page with the solution.

That’s it! I added the following lines to /System/Library/LaunchDaemons/org.apache.httpd.plist:

    <key>EnvironmentVariables</key>
    <dic>
        <key>FOO</key>
        <string>/bar</string>
    </dict>

and got the following results from exec(“export”):

Array
(
    [0] => export FOO="/bar"
    [1] => export OLDPWD
    [2] => export PATH="/usr/bin:/bin:/usr/sbin:/sbin"
    [3] => export PWD="/Library/WebServer/Documents"
    [4] => export SHLVL="1"
)

Case solved! Thanks all, thanks Axel.
Burt.

So that’s what I did. My /System/Library/LaunchDaemons/org.apache.httpd.plist file now looks alittle something like this:

<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
<plist version="1.0">
<dict>
	<key>EnvironmentVariables</key>
	<dict>
		<key>DYLD_LIBRARY_PATH</key>
		<string>/Applications/ImageMagick-6.4.4/lib</string>
		<key>MAGICK_HOME</key>
		<string>/Applications/ImageMagick-6.4.4</string>
		<key>PATH</key>
		<string>/Applications/ImageMagick-6.4.4/bin:/usr/bin:/bin:...</string>
	</dict>
	<key>Label</key>
	<string>org.apache.httpd</string>
	<key>OnDemand</key>
	<false/>
	<key>ProgramArguments</key>
	<array>
		<string>/usr/sbin/httpd</string>
		<string>-D</string>
		<string>FOREGROUND</string>
	</array>
	<key>SHAuthorizationRight</key>
	<string>system.preferences</string>
</dict>
</plist>

Thanks! I can finally go to sleep! :-)

<Swedish>

Men när jag försökte berätta för S vad jag har lyckats med så sa hon …

du är nördigare än vad man tror. glömmer ibland bort det.

… euhm … tack?!!

</Swedish>

Posted by David — Share: http://fmasc.net/as
Post new comment to Apache2, PHP5 and environment variables in OSX









Advance users: Click to view allowed XHTML tags.