简体   繁体   中英

How can I tell which external modules I have to install to PHP to replicate the configuration on another machine?

I can easily do

php -m

to see the list of the modules loaded by PHP, but the majority of them are included automatically in the base install.

What I need to see are the packages used and not present on a new system, in order to bring its configuration in line with an existing system.

For example, date shows up a module to PHP in the list, but there is no php-date package that needs to be installed and configured in order to use the date functions.

Conversely, mysql shows up in the list, but that doesn't come by default, so I need to install the php-mysql package. Some others, like xml additionally require libxml first. I need the list of the PHP modules that do not come by default (on an arbitrary configured machine).

This is only partially related to the question, but I'm trying to automate the config of PHP with the thias/php module at Puppetforge .

Is there any way to determine this reliably, quickly, and ideally, programmatically?

Here is a list created manually by running yum whatprovides php-$MODULENAME for each module in our config, and then capturing the package providing the module...

# root@dev$ php -m
# 'bz2',         # php-common
# 'calendar',    # php-common
# 'Core',        # php-common
# 'ctype',       # php-common
# 'curl',        # php-common
# 'date',        # php-common
# 'dom',         # php-xml
# 'ereg',        # php-common
# 'exif',        # php-common
# 'fileinfo',    # php-common
# 'filter',      # php-common
# 'ftp',         # php-common
  'gd',          # php-gd needs install
# 'gettext',     # php-common
# 'gmp',         # php-common
# 'hash',        # php-common
# 'iconv',       # php-common
# 'json',        # php-common
# 'libxml',      # php-common
  'memcache',    # php-pecl-memcache needs install
  'mysql',       # php-mysql needs install
# 'mysqli',      # php-mysql
# 'openssl',     # php-common
# 'pcntl',       # php-cli
# 'pcre',        # php-common
  'PDO',         # says php-pdo but in common as of 5.3
# 'pdo_mysql',   # php-mysql
# 'pdo_sqlite',  # php-pdo
# 'Phar',        # php-common
  'pspell',      # php-pspell needs install
# 'readline',    # php-cli
# 'Reflection',  # php-common
# 'session',     # php-common
# 'shmop',       # php-common
# 'SimpleXML',   # php-common
  'snmp',        # php-snmp
# 'sockets',     # php-common
# 'SPL',         # php-common
# 'sqlite3',     # php-pdo
# 'standard',    # php-common
# 'tokenizer',   # php-common
# 'wddx',        # php-xml
  'xml',         # php-xml needs install
# 'xmlreader',   # php-xml
  'xmlrpc',      # php-xmlrpc needs install
# 'xmlwriter',   # php-xml
# 'xsl',         # php-xml
# 'zip',         # php-common
# 'zlib'         # php-common

I ended up with this in params.pp

$php_modules        = ['gd','mysql','pspell','snmp','xml','xmlrpc']

and this in my php.pp profile.

package { 'php-pecl-memcached':
    ensure => installed,
}

php::module { $php_modules : }

I didn't end up doing it programmatically. Hope the list saves someone in the future some time - it took awhile to get it right!

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM