Adoptable Cookbooks List

Looking for a cookbook to adopt? You can now see a list of cookbooks available for adoption!
List of Adoptable Cookbooks

Supermarket Belongs to the Community

Supermarket belongs to the community. While Chef has the responsibility to keep it running and be stewards of its functionality, what it does and how it works is driven by the community. The chef/supermarket repository will continue to be where development of the Supermarket application takes place. Come be part of shaping the direction of Supermarket by opening issues and pull requests or by joining us on the Chef Mailing List.

Select Badges

Select Supported Platforms

Select Status

RSS

rackspace_nginx_php (5) Versions 0.0.4

Installs/Configures rackspace_nginx_php

Policyfile
Berkshelf
Knife
cookbook 'rackspace_nginx_php', '= 0.0.4', :supermarket
cookbook 'rackspace_nginx_php', '= 0.0.4'
knife supermarket install rackspace_nginx_php
knife supermarket download rackspace_nginx_php
README
Dependencies
Changelog
Quality 0%

Circle CI

rackspace_nginx_php-cookbook

A cookbook to provide a web server able to serve php pages with Nginx and PHP fpm.
It relies on nginx cookbook and php-fpm. Those cookbooks are pinned on well known working minor version to prevent breaking changes.
In addition (even if this is not a requirement), the cookbook will install php packages through PHP cookbook. Indeed most of the time you will need php::default in your role which will conflict with the php-fpm package if they are different.
You can disable the installation of php packages with node['rackspace_nginx_php']['php_packages_install']['enable'].

Supported Platforms

Attributes

  • node['rackspace_nginx_php']['php_version'] : Which PHP version to install, default to PHP 5.6
  • node['rackspace_nginx_php']['php-fpm']['default_pool']['enable'] : Should it enable a default PHP-FPM pool which listens on a unix socket
  • node['rackspace_nginx_php']['nginx']['default_site']['enable'] : Should it enable a default Nginx site which passes requests for php files to the default php-fpm pool
  • node['rackspace_nginx_php']['nginx']['default_site']['cookbook'] : Where to find the template for the default Nginx site configuration , default to rackspace_nginx_php cookbook
  • node['rackspace_nginx_php']['nginx']['default_site']['template'] : The name of the template for the default Nginx site configuration , default to default.conf.erb

Usage

Place a dependency on the rackspace_nginx_php cookbook in your cookbook's metadata.rb

depends 'rackspace_nginx_php'

Then, add rackspace_nginx_php::default to your runlist

# myrecipe.rb
include_recipe 'rackspace_nginx_php::default'

or

# roles/myrole.rb
name "myrole"
description "nginx and php role"
run_list(
  "rackspace_nginx_php::default"
)

You can change any of the nginx,php-fpm and php cookbook attributes to tune rackspace_nginx_php configuration.
** However you should not change ** ['php-fpm']['package_name'],['php-fpm']['service_name'] or ['php']['packages'] (as they are part of this cookbook logic) without checking it works.

In scope

The goal of this library is to do the basic configuration to serve PHP pages through Nginx. It will only configure Nginx and a default site and pool, users are free to use that or disable it and create their own Nginx sites and PHP-FPM pools.

More in details it :

  • Installs and configure Nginx web server
  • Installs and configure php-fpm
  • Installs and configure php
  • Configures Nginx to serve php pages through php-fpm
  • Gets the correct packages and change the configuration according to the php version

Out of scope

Virtual Host are not managed by this cookbook, the configuration provided by this cookbook should not prevent users to extend php or php-fpm configuration.
As many features as possible should have a flag to enable/disable them, it will allow to enjoy some parts of the work done by this cookbook (get the correct packages by example) but still be able to configure your own php-fpm pools.

Examples

Nginx and PHP 5.5

node.default['rackspace_nginx_php']['php_version'] = '5.5'
include_recipe 'rackspace_nginx_php::default'

Nginx and PHP 5.6

include_recipe 'rackspace_nginx_php::default'

Nginx and PHP 5.6 without the default Nginx site and PHP-FPM pool - Using attribute from upstream to define the pool

You will have to add your own Nginx site and PHP-FPM pool, here is an example using the upstream PHP-FPM attributes for the pool and a custom template for the Nginx site.

node.default['rackspace_nginx_php']['nginx']['default_site']['enable'] = false
node.default['rackspace_nginx_php']['php-fpm']['default_pool']['enable'] = false

# Create a php-fpm pool through the attribute exposed from upstream
node.default['php-fpm']['pools'] = {
  override: {
    enable: 'true',
    process_manager: 'dynamic',
    max_requests: 5000
  }
}

include_recipe 'rackspace_nginx_php::default'

# Create a nginx site to go with it (the template must be created by the user)
template "#{node['nginx']['dir']}/sites-available/override.conf" do
  source 'override.conf.erb'
  owner 'root'
  group 'root'
  mode '0644'
  action :create
end

nginx_site 'override.conf' do
  enable true
end

Nginx and PHP 5.6 without the default Nginx site and PHP-FPM pool - Using the php_fpm_pool definition to add a pool

You will have to add your own Nginx site and PHP-FPM pool, here is an example using the upstream PHP-FPM definition for the pool and a custom template for the Nginx site.

node.default['rackspace_nginx_php']['nginx']['default_site']['enable'] = false
node.default['rackspace_nginx_php']['php-fpm']['default_pool']['enable'] = false

# Create a php-fpm pool with default settings using the php_fpm_pool definition
php_fpm_pool 'override'

include_recipe 'rackspace_nginx_php::default'

# Create a nginx site to go with it (the template must be created by the user)
template "#{node['nginx']['dir']}/sites-available/override.conf" do
  source 'override.conf.erb'
  owner 'root'
  group 'root'
  mode '0644'
  action :create
end

nginx_site 'override.conf' do
  enable true
end

References

Contributing

  1. Fork the repository on Github
  2. Create a named feature branch (i.e. add-new-recipe)
  3. Write your change
  4. Write tests for your change (if applicable)
  5. Run the tests, ensuring they all pass
  6. Submit a Pull Request

License and Authors

Authors:: Kostas Georgakopoulos (kostas.georgakopoulos@rackspace.co.uk), Julien Berard (julien.berard@rackspace.co.uk)

Dependent cookbooks

apt >= 0.0.0
nginx = 2.7.6
chef-sugar >= 0.0.0
php = 1.5.0
php-fpm = 0.7.4
yum-ius >= 0.0.0

Contingent cookbooks

There are no cookbooks that are contingent upon this one.

rackspace_nginx_php CHANGELOG

0.0.4

  • Fix for rubocop tests

0.0.3

  • Improvements on integration tests

0.0.2

  • Pinned upstream cookbook versions
  • Added 'supports' statements to metadata
  • Various improvements and clean up on tests

0.0.1

  • First version

Foodcritic Metric
            

0.0.4 failed this metric

FC031: Cookbook without metadata file: /tmp/cook/bdb82104e7e7264291250105/rackspace_nginx_php/metadata.rb:1
FC045: Consider setting cookbook name in metadata: /tmp/cook/bdb82104e7e7264291250105/rackspace_nginx_php/metadata.rb:1