Acquia Drupal Stack - Adding PHP Extensions

Adding PHP extensions with phpize (Mac OS X only)

The Acquia Drupal stack includes includes phpize to allow users to build php extensions that will match the version of PHP it runs.

Required: Apple Xcode Tools

This process relies on utilities contained in Apple's Xcode tools. These come on every OS X installation disk and are also available at http://developer.apple.com/tools/xcode/. Be sure you have installed "Developer Tools Essentials" and "UNIX Development Support" (also called "UNIX Dev Support" on some versions) on your system before continuing with these instructions.

Install PHP extension

You can build and add any compatible extension from the PECL repository. The following example shows how to add support for LZF compression using the corresponding PECL extension.

Note: Dependencies - Some extensions have dependencies on other extensions and libraries. Check the project page and instructions of the extension you wish to install and include all dependencies as required.

  1. Download PHP extension tarball - Find the extension you need at http://pecl.php.net/ and navigate to its project page. For our example, that is http://pecl.php.net/package/lzf. Copy the link to the version of the archive you require and download it to your computer:

    curl -O http://pecl.php.net/get/LZF-1.5.2.tgz
  2. Untar PHP extension archive using a command like this:

    tar -zxvf LZF-1.5.2.tgz
  3. Build PHP extension - The following command example assumes you have installed the Acquia Drupal stack in its standard location (/Applications/acquia-drupal/). If you have installed it somewhere else, modify the following commands accordingly.

    On the command line, navigate inside the extension directory, then run the following commands, one at a time:

    /Applications/acquia-drupal/php/bin/phpize
    ./configure --with-php-config=/Applications/acquia-drupal/php/bin/php-config
    make
  4. Add PHP extension to DAMP stack - The following command example assumes you have installed the Acquia Drupal stack in its standard location (/Applications/acquia-drupal/). If you have installed it somewhere else, modify the following commands accordingly.

    The 'make' command will have made a 'modules' directory within the extension source directory. Copy the module to the DAMP stack's extensions directory with a command like this:

    cp modules/*.so /Applications/acquia-drupal/php/ext
  5. Register PHP extension - The following command example assumes you have installed the Acquia Drupal stack in its standard location (/Applications/acquia-drupal/). If you have installed it somewhere else, modify the following commands accordingly.

    The 'modules' directory you copied in the previous step contains a .so file. Add a line like the following (using the appropriate name) to the "Dynamic Extensions" section of the DAMP stack's php.ini file, which can be found at: /Applications/acquia-drupal/php/bin/php.ini

    extension=lzf.so
  6. Restart Apache - using the main Stop/Start button on the Acquia DAMP stack control panel.