Take the 2-minute tour ×
Server Fault is a question and answer site for system and network administrators. It's 100% free, no registration required.

Configuration where this problem occurs: OSX 10.7, XAMPP Mac OS X 1.7.3, Image Magic installed with homebrew, Apple Websharing turned OFF.

Problem description: Can't install Imagick PHP extension for Image Magic due to problems with PHP version between OSX and XAMPP.

I installed XAMPP in the latest version together with the XAMPP development tool.

Then I like to add the Imagick extension to my PHP configuration by using PECL to install the Image Magic wrapper.

cd /Applications/XAMPP/xamppfiles/bin 
sudo ./pecl install imagick

The result says installed successful. When opening a PHP files that uses Imagick I get the following error

Fatal error: Class 'imagick' not found in /Users/philipp/appbackr/code/site/trunk/include/function.php on line 439

As far as I understand is the error the following: XAMPP uses PHP ver 5.3.1 When using PECL for installing and building Imagick it looks like that it's using OSX 10.7 build in PHP ver 5.3.6. The version difference is shown by executing a phpinfo() within XAMPP and with PHP phpinfo.php in the command line.

I look to me that the PECL installation is build with the default PHP version that is shipped with Lion and that this is causing a problem.

How can I get this running on my local machine? What do I have to configure so that I can install XAMPP extensions with PECL.

share|improve this question

migrated from stackoverflow.com Aug 4 '11 at 4:47

This question came from our site for professional and enthusiast programmers.

    
So what should be my strategy on where to post it? –  philipp Aug 2 '11 at 1:54
    
Quick question before we get hung up on versions: you did enable extension=imagick.so somewhere in you PHP configuration, didn't you? –  Wrikken Aug 2 '11 at 1:55
    
What do you mean by default PHP? Is it a seperate PHP installation package? In this case, just change environment variables to use the new php path. –  Starx Aug 2 '11 at 2:03
    
    
@Wriken: extension=imagick.so is enabled and I gave it also the same permissions as other extensions –  philipp Aug 3 '11 at 17:41

1 Answer 1

Actually I have run into similar problems with XAMPP. The problem your running into is that it is very easy to get mixed up with which copy of php you are working with. When your running something from your XAMPP web directory it is a pretty safe bet that the PHP version is the one that came with XAMPP.

However, you can still make this work. First of all, go to the command line and type in "which php". That will tell you which install of php that you are running there.

Now in order to change it you need to modify your Mac startup a bit.

You need to go to "/Library/StartupItems/" and create a folder called "xampp". In that folder put these two files with the following content to get xampp to come up first.

StartupParameters.plist
--------------------------
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE plist SYSTEM "file://localhost/System/Library/DTDs/PropertyList.dtd">
<plist version="0.9">
  <dict>
    <key>Description</key>
    <string>XAMPP</string>
    <key>OrderPreference</key>
    <string>Late</string>
    <key>Provides</key>
    <array>
      <string>Starts Apache and MySQL</string>
    </array>
    <key>Uses</key>
    <array>
      <string>SystemLog</string>
    </array>
  </dict>
</plist>

===============================
xampp
--------------------------
#!/bin/sh
/Applications/XAMPP/xamppfiles/xampp start

You will also need to add this to your ".profile" file in your user directory.

PATH=/Applications/XAMPP/xamppfiles/bin:$PATH
LD_LIBRARY_PATH=/Applications/XAMPP/xamppfiles/lib:$LD_LIBRARY_PATH
LD_LIBRARY_PATH=/Applications/XAMPP/xamppfiles/lib/mysql:$LD_LIBRARY_PATH

Then you need to reboot and check which php your running again. I think this will do it for you. If it does then you should be able to install whatever you want. Also you can go to the xampp bin directory and run "./php SOME_PHP_COMMAND" to directly target that PHP install. Also you can also try dropping the imagemagick module into the php module/extensions directory in xampp and then just put it into the php.ini file to get it to load.

share|improve this answer
    
Thank you very much. That was very helpful and changed the version of the PHP version. Somehow Imagick is still not working. I'm just installing a Ubuntu machine in a VM now... –  philipp Aug 3 '11 at 6:15

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.