Search code examples
apacheubuntuvagrantchef-solo

Enable apache2 in prefork mode using Chef


I' trying to install apache2 and php in a Vagrant box (Ubuntu 14.04) using Chef Solo. This is my recipe:

include_recipe "apache2"
include_recipe "apache2::mod_rewrite"
include_recipe "apache2::mod_ssl"
include_recipe "apache2::mod_php5"

### some changes due to php5 reqs. ###
#-------------------------------------
apache_module "mpm_event" do
  enable false
end

apache_module "mpm_prefork" do
  enable true
end

service "apache2" do
  action :restart
end

This because apache2 is installed with mpm_event by default, and I need to change it because of php.

For some reasons, this not always works (sometimes, apache2 won't restart due to mpm_event still enabled), so I'm searching a more idiomatic and chef-safe way to install apache2 directly with prefork module rather than event.

Is there a way to do so?


Solution

  • It is possible to set mpm in vagrant file

      config.vm.provision "chef_solo" do |chef|
        chef.json = {
          "apache" => {
            "mpm" => "prefork"
          }
        }
      end