aporat / php55-cookbook

PHP 5.5 Chef Cookbook for Ubuntu, Centos and Amazon Linux AMI
Apache License 2.0
9 stars 5 forks source link

Support for ubuntu #1

Open riotCode opened 10 years ago

riotCode commented 10 years ago

It seems that this recipe doesn't actually configure for ubuntu, the final when "debian" is only referencing the "platform" not the "platform_family". Included "ubuntu" but the package did not install properly. Soooo... I made a make shift block before it for ubuntu. I would have done a pull request but I am a complete chef/ruby noob so I doubt this is best practice but I figured it could help someone who could apply what I did in a better fashion. :8ball:

 when "ubuntu"
    include_recipe "apt"

    execute "python-software-properties" do 
      command "apt-get install -y python-software-properties"
      action :run
    end

    execute "install php55" do
      #command "apt-get install -y php5"
      command "add-apt-repository ppa:ondrej/php5 && apt-get update -y && apt-get install -y php5 php5-mcrypt php5-json"
      action :run
    end

    execute "restart apache2" do
      #command "apt-get install -y php5"
      command "service apache2 restart"
      action :run
    end

This works flawlessly on my Vagrant Ubuntu 12.04 provisioning. I might test it on AWS Opsworks later on. Keep in mind the repo installs apache 2.4 as a dependancy so running most apache2 recipes usually cause errors because there are some breaking changes between 2.4 and older versions. I hope this helps, thank you :)

arvidbjorkstrom commented 10 years ago

If someone finds this via google, like I did, I thought I'd share the code I ended up with

when "ubuntu"
    include_recipe "apt"

    package "python-software-properties" do
        action :install
    end

    apt_repository "ondrej-php-#{node["lsb"]["codename"]}" do
        uri "http://ppa.launchpad.net/ondrej/php5/ubuntu"
        distribution node["lsb"]["codename"]
        components ["main"]
        keyserver "keyserver.ubuntu.com"
        key "E5267A6C"
    end

    [ "php5", "php5-mysql", "php5-curl", "php5-mcrypt" ].each do |pkg|
        package pkg do
            action :install
            version "5.5.*"
            notifies :restart, "service[apache2]", :delayed
            notifies :run, "execute[apt-get autoremove]", :delayed
        end
    end
end

or, even better, use the php5_ppa cookbook: http://community.opscode.com/cookbooks/php5_ppa replacing

    apt_repository "ondrej-php-#{node["lsb"]["codename"]}" do
        uri "http://ppa.launchpad.net/ondrej/php5/ubuntu"
        distribution node["lsb"]["codename"]
        components ["main"]
        keyserver "keyserver.ubuntu.com"
        key "E5267A6C"
    end

with

include_recipe "php5_ppa::from_ondrej"

I'd also recommend taking a look at the apache 2.4 cookbook here http://github.com/onehealth-cookbooks/apache2-onehealth