自从我上一个关于使用 chef 为 vagrant 控制的 Ubuntu 基本机器配置 PHP 5.4 的问题以来,我觉得我向前迈了一步,又向后退了两步。我已经放弃尝试使用 apt 来获取正确版本的 PHP,而是决定尝试使用源代码构建。
我的食谱
# Name of the role should match the name of the file
name "webserver"
default_attributes(
"build_essential" => {
"compiletime" => true
}
)
override_attributes(
"mysql" => {
"server_root_password" => 'reverse',
"server_repl_password" => 'reverse',
"server_debian_password" => 'reverse'
},
"php" => {
"install_method" => "source",
"php54" => true
}
)
# Run list function we mentioned earlier
run_list(
"recipe[apt]",
"recipe[build-essential]",
"recipe[xml]",
"recipe[chef-php54]",
"recipe[openssl]",
"recipe[apache2]",
"recipe[apache2::vhosts]",
"recipe[apache2::mod_rewrite]",
"recipe[apache2::mod_ssl]",
"recipe[mysql]",
"recipe[mysql::server]",
"recipe[php]",
"recipe[php::module_gd]",
"recipe[php::module_curl]",
"recipe[php::module_mysql]",
"recipe[php::module_apc]",
"recipe[chef-php-extra::default]",
"recipe[chef-php-extra::development]",
"recipe[apache2::mod_php5]",
"recipe[database::mysql]",
"recipe[database::import]",
"recipe[memcached]",
"recipe[varnish]"
)
我时没有明显的错误消息vagrant up
;而这一次,当我 ssh 到盒子并做时php -v
,我至少可以看到
PHP 5.4.15 (cli) (built: Jul 18 2013 17:42:34)
Copyright (c) 1997-2013 The PHP Group
Zend Engine v2.4.0, Copyright (c) 1998-2013 Zend Technologies
这是向前迈出的一步。
第一步是首先php -v
显示的大量消息:
Failed loading /usr/lib/php5/20090626/xdebug.so: /usr/lib/php5/20090626/xdebug.so: undefined symbol: output_globals
PHP Warning: PHP Startup: Unable to load dynamic library '/usr/local/lib/php/extensions/no-debug-non-zts-20100525/apc.so' - /usr/local/lib/php/extensions/no-debug-non-zts-20100525/apc.so: cannot open shared object file: No such file or directory in Unknown on line 0
PHP Warning: PHP Startup: Unable to load dynamic library '/usr/local/lib/php/extensions/no-debug-non-zts-20100525/gd.so' - /usr/local/lib/php/extensions/no-debug-non-zts-20100525/gd.so: cannot open shared object file: No such file or directory in Unknown on line 0
PHP Warning: PHP Startup: Unable to load dynamic library '/usr/local/lib/php/extensions/no-debug-non-zts-20100525/mcrypt.so' - /usr/local/lib/php/extensions/no-debug-non-zts-20100525/mcrypt.so: cannot open shared object file: No such file or directory in Unknown on line 0
PHP Warning: PHP Startup: Unable to load dynamic library '/usr/local/lib/php/extensions/no-debug-non-zts-20100525/mysql.so' - /usr/local/lib/php/extensions/no-debug-non-zts-20100525/mysql.so: cannot open shared object file: No such file or directory in Unknown on line 0
PHP Warning: PHP Startup: Unable to load dynamic library '/usr/local/lib/php/extensions/no-debug-non-zts-20100525/mysqli.so' - /usr/local/lib/php/extensions/no-debug-non-zts-20100525/mysqli.so: cannot open shared object file: No such file or directory in Unknown on line 0
PHP Warning: PHP Startup: Unable to load dynamic library '/usr/local/lib/php/extensions/no-debug-non-zts-20100525/pdo.so' - /usr/local/lib/php/extensions/no-debug-non-zts-20100525/pdo.so: cannot open shared object file: No such file or directory in Unknown on line 0
PHP Warning: PHP Startup: Unable to load dynamic library '/usr/local/lib/php/extensions/no-debug-non-zts-20100525/pdo_mysql.so' - /usr/local/lib/php/extensions/no-debug-non-zts-20100525/pdo_mysql.so: cannot open shared object file: No such file or directory in Unknown on line 0
第二步是当我将浏览器指向 phpinfo() 文件时,它仍然显示PHP Version 5.3.10-1ubuntu3.7
;所以很明显 mod_php 仍然选择了错误的版本。
使用像 chef 这样的配置工具可能被认为是最佳实践,但是当我浪费了 6 天的时间来努力完成我可以在几个小时内手动完成的事情时,我发现它非常令人沮丧。
谷歌似乎对提供任何答案毫无用处:任何人都可以帮助我指出正确的方向并向我证明厨师确实是最佳实践,而不仅仅是浪费时间和精力。