cookbook 'rackspace_nginx_php', '~> 1.0.0'
rackspace_nginx_php (5) Versions 1.0.0 Follow0
Installs/Configures rackspace_nginx_php
cookbook 'rackspace_nginx_php', '~> 1.0.0', :supermarket
knife supermarket install rackspace_nginx_php
knife supermarket download rackspace_nginx_php
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']
.
***
NOTE: Support for PHP 5.4 was dropped in v1.0.0
***
Supported Platforms
- Centos 6.7
- Ubuntu 12.04
- Ubuntu 14.04 (only PHP 5.5 and 5.6)
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 torackspace_nginx_php cookbook
-
node['rackspace_nginx_php']['nginx']['default_site']['template']
: The name of the template for the default Nginx site configuration , default todefault.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
- Fork the repository on Github
- Create a named feature branch (i.e.
add-new-recipe
) - Write your change
- Write tests for your change (if applicable)
- Run the tests, ensuring they all pass
- 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
1.0.0
- Release as v1.0.0
- Dropped support for PHP 5.4
- Updated unit tests
0.0.5
- Support for CentOS 6.7 instead of 6.6
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
Collaborator Number Metric
1.0.0 failed this metric
Failure: Cookbook has 1 collaborators. A cookbook must have at least 2 collaborators to pass this metric.
Contributing File Metric
1.0.0 failed this metric
Failure: To pass this metric, your cookbook metadata must include a source url, the source url must be in the form of https://github.com/user/repo, and your repo must contain a CONTRIBUTING.md file
Foodcritic Metric
1.0.0 passed this metric
No Binaries Metric
1.0.0 passed this metric
Testing File Metric
1.0.0 failed this metric
Failure: To pass this metric, your cookbook metadata must include a source url, the source url must be in the form of https://github.com/user/repo, and your repo must contain a TESTING.md file
Version Tag Metric
1.0.0 failed this metric
Failure: To pass this metric, your cookbook metadata must include a source url, the source url must be in the form of https://github.com/user/repo, and your repo must include a tag that matches this cookbook version number
1.0.0 failed this metric
1.0.0 failed this metric
Failure: To pass this metric, your cookbook metadata must include a source url, the source url must be in the form of https://github.com/user/repo, and your repo must contain a CONTRIBUTING.md file
Foodcritic Metric
1.0.0 passed this metric
No Binaries Metric
1.0.0 passed this metric
Testing File Metric
1.0.0 failed this metric
Failure: To pass this metric, your cookbook metadata must include a source url, the source url must be in the form of https://github.com/user/repo, and your repo must contain a TESTING.md file
Version Tag Metric
1.0.0 failed this metric
Failure: To pass this metric, your cookbook metadata must include a source url, the source url must be in the form of https://github.com/user/repo, and your repo must include a tag that matches this cookbook version number
1.0.0 passed this metric
1.0.0 passed this metric
Testing File Metric
1.0.0 failed this metric
Failure: To pass this metric, your cookbook metadata must include a source url, the source url must be in the form of https://github.com/user/repo, and your repo must contain a TESTING.md file
Version Tag Metric
1.0.0 failed this metric
Failure: To pass this metric, your cookbook metadata must include a source url, the source url must be in the form of https://github.com/user/repo, and your repo must include a tag that matches this cookbook version number
1.0.0 failed this metric
1.0.0 failed this metric
Failure: To pass this metric, your cookbook metadata must include a source url, the source url must be in the form of https://github.com/user/repo, and your repo must include a tag that matches this cookbook version number