简体   繁体   English

如何确定必须将哪些外部模块安装到PHP才能在另一台计算机上复制配置?

[英]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. 查看由PHP加载的模块列表,但其中的大多数模块自动包含在基本安装中。

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. 例如, date在列表中显示了PHP的模块,但是没有安装和配置php-date软件包才能使用date函数。

Conversely, mysql shows up in the list, but that doesn't come by default, so I need to install the php-mysql package. 相反, mysql显示在列表中,但是默认情况下不是这样,因此我需要安装php-mysql软件包。 Some others, like xml additionally require libxml first. 其他一些(例如xml)首先需要libxml。 I need the list of the PHP modules that do not come by default (on an arbitrary configured machine). 我需要默认情况下(在任意配置的计算机上)不存在的PHP模块列表。

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 . 这仅与问题部分相关,但是我正在尝试使用Puppetforge的thias / php模块自动化PHP的配置。

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... 这是通过为配置中的每个模块运行yum whatprovides php-$MODULENAME并随后捕获提供该模块的软件包而手动创建的列表...

# 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 我最终在params.pp中找到了这个

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

and this in my php.pp profile. 这在我的php.pp个人资料中。

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! 希望这份清单能在以后节省一些人-花了一段时间才弄对了!

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

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