PHP + Apache in Mac OS X with ImageMagick (paths)
Posted: 2010-02-26T09:58:09-07:00
I was able to get ImageMagick to install and work under Terminal prompt in Mac OS X. But, PHP cannot "see" the paths set, unless I use putenv or create a "wrapper" shell script.
I have the following in /private/etc/profile
export MAGICK_HOME="/usr/local/ImageMagick"
export PATH="$MAGICK_HOME/bin:$PATH"
export DYLD_LIBRARY_PATH="$MAGICK_HOME/lib"
In a new Terminal window, typing "convert --version" displays the version info as expected.
However, in PHP, I have this...
passthru("echo \$PATH");
passthru("echo \$DYLD_LIBRARY_PATH");
passthru("convert -version",$ret);
The Path variable only shows the default system path (not the /usr/local/ImageMagick appended to it), and DYLD_LIBRARY_PATH is empty, even though they are both set in the /private/etc/profile and display when typing the commands from the Terminal. The Apache user, _www doesn't seem to load the profile.
I tried SetEnv in httpd.conf, but it doesn't help. The only way I could get it to work was with these 2 lines at the top of my PHP page.
putenv("PATH={$_SERVER["PATH"]}:/usr/local/ImageMagick/bin");
putenv("DYLD_LIBRARY_PATH=/usr/local/ImageMagick/lib");
Certainly someone else has been able to get ImageMagick + Apache + PHP on Mac OS X to work without using putenv. (That's not a good solution for me, since I use this as a Development area, and the live copy has different paths).
How do I get _www user to set the path/env. variables (or "read" the /private/etc/profile)?
For the time-being, I have a wrapper script and an alias set up in /usr/bin (which is in the _www user's path), but I really don't want to keep it that way.
Anyone know how to get _www "see" the profile variables that are set in /private/etc/profile?? I have been all over various forum posts and Google, and cannot find an answer (besides MacPorts). I've wasted about 3 hours, and since this is related to ImageMagick, I decided to try posting here first....
Thanks in advanced for any assistance.
-Jim
Running: OS X 10.6.2
I have the following in /private/etc/profile
export MAGICK_HOME="/usr/local/ImageMagick"
export PATH="$MAGICK_HOME/bin:$PATH"
export DYLD_LIBRARY_PATH="$MAGICK_HOME/lib"
In a new Terminal window, typing "convert --version" displays the version info as expected.
However, in PHP, I have this...
passthru("echo \$PATH");
passthru("echo \$DYLD_LIBRARY_PATH");
passthru("convert -version",$ret);
The Path variable only shows the default system path (not the /usr/local/ImageMagick appended to it), and DYLD_LIBRARY_PATH is empty, even though they are both set in the /private/etc/profile and display when typing the commands from the Terminal. The Apache user, _www doesn't seem to load the profile.
I tried SetEnv in httpd.conf, but it doesn't help. The only way I could get it to work was with these 2 lines at the top of my PHP page.
putenv("PATH={$_SERVER["PATH"]}:/usr/local/ImageMagick/bin");
putenv("DYLD_LIBRARY_PATH=/usr/local/ImageMagick/lib");
Certainly someone else has been able to get ImageMagick + Apache + PHP on Mac OS X to work without using putenv. (That's not a good solution for me, since I use this as a Development area, and the live copy has different paths).
How do I get _www user to set the path/env. variables (or "read" the /private/etc/profile)?
For the time-being, I have a wrapper script and an alias set up in /usr/bin (which is in the _www user's path), but I really don't want to keep it that way.
Anyone know how to get _www "see" the profile variables that are set in /private/etc/profile?? I have been all over various forum posts and Google, and cannot find an answer (besides MacPorts). I've wasted about 3 hours, and since this is related to ImageMagick, I decided to try posting here first....
Thanks in advanced for any assistance.
-Jim
Running: OS X 10.6.2