简体   繁体   English

无法让厨师在Ubuntu虚拟机上配置PHP 5.4.x

[英]Can't get chef to provision PHP 5.4.x on an Ubuntu virtual box

I feel as though I've taken a step forward and two steps back since my last question about using chef to provision PHP 5.4 for an Ubuntu base box controlled by vagrant. 自从上一个关于使用厨师为由vagrant控制的Ubuntu基本框提供PHP 5.4的问题以来,我感觉好像已经前进了两步。 I've given up on trying to use apt to pull the right version of PHP, and decided to try a source build instead. 我已经放弃尝试使用apt来拉正确版本的PHP,并决定尝试使用源代码构建。

My recipe 我的食谱

# 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]"
)

No obvious error messages when I vagrant up ; vagrant up时没有明显的错误信息; and this time, when I ssh to the box and do php -v , I do at least get to see 而这一次,当我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

That's one step forward. 这是前进的一步。

First step back is the slew of messages that php -v shows first: 第一步后退是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

Second step back is when I point a browser at a phpinfo() file, it still shows PHP Version 5.3.10-1ubuntu3.7 ; 第二步是当我将浏览器指向phpinfo()文件时,它仍然显示PHP Version 5.3.10-1ubuntu3.7 so clearly the mod_php is still picking up the wrong version. 很明显,mod_php仍然选择了错误的版本。

Using a provisioning tool like chef might be considered best practise, but when it's wasted 6 days of my time struggling to get nowhere for something I could have done manually in a couple of hours I find it pretty frustrating. 使用诸如Chef之类的置备工具可能被认为是最佳实践,但是当我浪费了6天的时间而无法完成我本可以在几个小时内手动完成的工作时,我感到非常沮丧。

Google seems pretty useless for providing any answers: can anybody help point me in the right direction and prove to me that chef really is best practise and not simply a waste of time and effort. Google似乎无法提供任何答案:任何人都可以帮助我指出正确的方向,并向我证明厨师确实是最佳实践,而不仅仅是浪费时间和精力。

Download latest Ubuntu server 下载最新的Ubuntu服务器

Create a new virtualmachine with virtualbox i used the name 'devbox_ubuntu' 使用virtualbox创建一个新的虚拟机,我使用的名称为'devbox_ubuntu'

Boot your virtualmachine and install the needed packages for chef/vagrant 引导您的虚拟机并安装厨师/流浪者所需的软件包

$ sudo bash
$ apt-get install sudo ruby ruby-dev libopenssl-ruby rdoc ri irb build-essential ssl-cert curl rubygems puppet


$ echo “deb http://apt.opscode.com/ `lsb_release -cs`-0.10 main”    tee /etc/apt/sources.list.d/opscode.list
$ gpg --keyserver keys.gnupg.net --recv-keys 83EF826A
$ gpg --export packages@opscode.com | tee /etc/apt/trusted.gpg.d/opscode-keyring.gpg > /dev/null

$ apt-get update
$ apt-get install opscode-keyring chef

fill in none for the URL 不填写网址

Add the vagrant user 添加无业游民的用户

$ adduser vagrant
passwrd : vagrant
$ groupadd admin
$ usermod -a -G admin vagrant

Setup sudo for the admin group 为管理员组设置sudo

$ visudo
%admin ALL=(ALL) NOPASSWD: ALL

Disable DNS for SSHD 禁用SSHD的DNS

$ vi /etc/etc/ssh/sshd_config
UseDNS no

SU to the vagrant user and setup the SSH key SU到无业游民的用户并设置SSH密钥

$ su vagrant
$ mkdir -p ~/.ssh
$ chmod 0700 ~/.ssh
$ curl -o ~/.ssh/authorized_keys https://raw.github.com/mitchellh/vagrant/master/keys/vagrant.pub
$ chmod 0600 ~/.ssh/authorized_keys

halt the VM and setup the VM with vagrant on the local machine 停止虚拟机并在本地计算机上使用流浪汉设置虚拟机

$ vagrant package --base devbox_ubuntu
$ mv package.box devbox_ubuntu.box

Wait a while ... 等一会儿 ...

$ vagrant box add devbox_ubuntu devbox_ubuntu.box
$ mkdir devbox_ubuntu && cd devbox_ubuntu
$ vagrant init devbox_ubuntu
$ vagrant up

[default] Importing base box 'devbox_ubuntu'... .... lots of output [默认]导入基本框'devbox_ubuntu'... ....很多输出

Do a test SSH login to see if it all works 做一个测试SSH登录以查看是否一切正常

$ vagrant ssh
$ exit
$ vagrant halt
$ vagrant destroy

Cool. 凉。 So that's all there. 这就是全部。 Now setup some recipes (apache2 and dotdeb php 5.4) 现在设置一些食谱(apache2和dotdeb php 5.4)

$ mkdir cookbooks
$ cd cookbooks

$ git clone https://github.com/opscode-cookbooks/apache2
$ git clone https://github.com/tlenss/misc.git
$ mv misc/chef/cookbooks/dotdeb .
$ rm -rf misc

Setup the recipes in the Vagrantfile 在Vagrantfile中设置配方

$ cd ..
$ vi Vagrantfile

config.vm.provision :chef_solo do |chef|
     chef.cookbooks_path = "cookbooks"
     chef.add_recipe("dotdeb")
     chef.add_recipe("dotdeb::php54")
     chef.add_recipe("apache2");
     chef.add_recipe("apache2::mod_php5");
end

Boot the VM again and let chef do it's thing. 再次启动虚拟机,然后让厨师做。 Once done. 一旦完成。 Login and verify the PHP version 登录并验证PHP版本

$ vagrant up
$ vagrant ssh
$ php -v

PHP 5.4.17-1~dotdeb.0 (cli) (built: Jul  6 2013 17:53:27) 
Copyright (c) 1997-2013 The PHP Group
Zend Engine v2.4.0, Copyright (c) 1998-2013 Zend Technologies

I used a modified dotdeb cookbook by Yevgeniy Viktorov. 我使用了Yevgeniy Viktorov修改过的dotdeb食谱。 And wrote a small article about it a while back. 不久前写了一篇关于它的小文章 It might be helpful! 可能会有帮助!

Adding additional PHP extensions i use the chef's standard PHP recipes from https://github.com/opscode-cookbooks/php . 添加其他PHP扩展名我使用来自https://github.com/opscode-cookbooks/php的厨师的标准PHP食谱。 Apparently Ubuntu and dotdeb's PHP 5.4 have a dependency issue with libmysqlclient. 显然,Ubuntu和dotdeb的PHP 5.4与libmysqlclient存在依赖关系问题。 Using mysqlnd instead of mysql should fix this 使用mysqlnd代替mysql应该解决这个问题

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

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