Search code examples
phppearansible

Can I rely on php extensions to be stored in /usr/lib/php5/20121212


I'm creating an ansible role that installs a pear module (pam). I want the role to check if the module is already installed using a creates= clause.

This module installs itself in /usr/lib/php5/20121212/pam.so but it feels a bit shaky to rely on that. What is a better way to find out where the php extension modules are stored?


Solution

  • No, it's not safe to make assumptions about the install location. The PHP module API number changes with each PHP major version. For instance, 20121212 is the API number used for PHP 5.5. Additionally, the exact path will change based on configuration. For instance, my PHP 5.5 system stores extensions in /usr/lib/php/extensions/no-debug-non-zts-20121212.

    To get the default extension install location for a specific version of PHP, run php-config --extension-dir, using the php-config binary installed for that PHP version.