yevgenko / cookbook-php-fpm Goto Github PK
View Code? Open in Web Editor NEWInstalls/Configures php-fpm
Home Page: http://community.opscode.com/cookbooks/php-fpm
License: Apache License 2.0
Installs/Configures php-fpm
Home Page: http://community.opscode.com/cookbooks/php-fpm
License: Apache License 2.0
if start_servers param is not defined it shouldnt be set to an arbitrary value in the pool config, since its not mandatory (it defaults to the avg of min and max spares ) and it will be invalid if it is outside the range of min and max spares.
e.g.:
min_spare_servers: 8
max_spare_servers: 16
start_servers: not defined in parameters => 5
result: invalid config and pool fail to restart
When trying to run on an Ubuntu 14.04 (Trusty) box, I get this error below.
Specific box: https://cloud-images.ubuntu.com/vagrant/trusty/current/trusty-server-cloudimg-i386-vagrant-disk1.box
It does work fine on a Precise box.
[2014-04-27T19:21:37+00:00] INFO: service[nginx] reloaded
[2014-04-27T19:21:37+00:00] INFO: template[/etc/php5/fpm/php-fpm.conf] sending restart action to service[php-fpm] (delayed)
[2014-04-27T19:21:37+00:00] ERROR: Running exception handlers
[2014-04-27T19:21:37+00:00] ERROR: Exception handlers complete
[2014-04-27T19:21:37+00:00] FATAL: Stacktrace dumped to /var/chef/cache/chef-stacktrace.out
[2014-04-27T19:21:37+00:00] ERROR: Chef::Exceptions::MultipleFailures
================================================================================
Error executing action `restart` on resource 'service[php-fpm]'
================================================================================
ArgumentError
-------------
invalid byte sequence in US-ASCII
Resource Declaration:
---------------------
# In /tmp/vagrant-chef-2/chef-solo-1/cookbooks/php-fpm/recipes/default.rb
114: service "php-fpm" do
115: provider service_provider if service_provider
116: service_name php_fpm_service_name
117: supports :start => true, :stop => true, :restart => true, :reload => true
118: action [ :enable, :start ]
119: end
120:
Compiled Resource:
------------------
# Declared in /tmp/vagrant-chef-2/chef-solo-1/cookbooks/php-fpm/recipes/default.rb:114:in `from_file'
service("php-fpm") do
provider Chef::Provider::Service::Upstart
action [:enable, :start]
supports {:start=>true, :stop=>true, :restart=>true, :reload=>true}
retries 0
retry_delay 2
service_name "php5-fpm"
pattern "php-fpm"
startup_type :automatic
cookbook_name :"php-fpm"
recipe_name "default"
end
[2014-04-27T19:17:34+00:00] INFO: Forking chef instance to converge...
[2014-04-27T19:21:38+00:00] FATAL: Chef::Exceptions::ChildConvergeError: Chef run process exited unsuccessfully (exit code 1)
Basic run list...
run_list(
"recipe[nginx]",
"recipe[php]",
"recipe[php-fpm]"
)
After installing php70-fpm in CentOS 7, I realized that the default name for the service is not 'php-fpm' but 'php-fpm-7.0'.
With that in mind, the 'notifies' sentences in php-fpm/definitions/php_fpm_pool.rb:26 causes the cookbook to fail with the message:
" resource template[/etc/php-fpm.d/default.conf] is configured to notify resource service[php-fpm] with action restart, but service[php-fpm] cannot be found in the resource collection. template[/etc/php-fpm.d/default.conf] is defined in /var/chef/runs/d9de713f-ec45-4cd7-8033-25af29433649/local-mode-cache/cache/cookbooks/php-fpm/definitions/php_fpm_pool.rb:26:in `block in from_file'"
Coudn't find a way to change the default service name, and also the service name is hard coded in this part of the cookbook.
"Development" section of readme file need be updated as per recent switch to "Chef Development Kit" (PR #102)
Not sure if this is an issue with this cookbook or with the Upstart stuff provided by Chef, but it causes some weird issues at times with restarting the service. I've tried overriding using node.default['php-fpm']['pid'] = '/run/php5-fpm.pid'
in my wrapper cookbooks, but it does nothing and /var/run/php5-fpm.pid
remains the setting specified in /etc/init.d/php-fpm
.
Any chance you can update the php5-fpm properties on the Supermarket site. The cookbook currently doesn't link back to Github. Also the Changelog in the repo here should be new to old not old to new. Supermarket sends short update e-mails including the changelog, but it only includes the top.
When I simply do include_recipe "php-fpm"
, I get a recipe compile error. If I use the definition directly and install PHP-FPM from another recipe, it works fine. I think the solution would be to remove:
default['php-fpm']['pools'] = [ { :name => "www" } ]
from the attributes.
Stack trace:
================================================================================
Recipe Compile Error in /tmp/vagrant-chef-1/chef-solo-1/cookbooks/my_site/recipes/default.rb
================================================================================
TypeError
---------
can't convert Symbol into Integer
Cookbook Trace:
---------------
/tmp/vagrant-chef-1/chef-solo-1/cookbooks/php-fpm/recipes/default.rb:123:in `[]'
/tmp/vagrant-chef-1/chef-solo-1/cookbooks/php-fpm/recipes/default.rb:123:in `block in from_file'
/tmp/vagrant-chef-1/chef-solo-1/cookbooks/php-fpm/recipes/default.rb:122:in `each'
/tmp/vagrant-chef-1/chef-solo-1/cookbooks/php-fpm/recipes/default.rb:122:in `from_file'
/tmp/vagrant-chef-1/chef-solo-1/cookbooks/apfaph/recipes/default.rb:1:in `from_file'
/tmp/vagrant-chef-1/chef-solo-1/cookbooks/my_site/recipes/frontend.rb:8:in `from_file'
/tmp/vagrant-chef-1/chef-solo-1/cookbooks/my_site/recipes/default.rb:38:in `from_file'
Relevant File Content:
----------------------
/tmp/vagrant-chef-1/chef-solo-1/cookbooks/php-fpm/recipes/default.rb:
116: service_name php_fpm_service_name
117: supports :start => true, :stop => true, :restart => true, :reload => true
118: action [ :enable, :start ]
119: end
120:
121: if node['php-fpm']['pools']
122: node['php-fpm']['pools'].each do |pool|
123>> php_fpm_pool pool[:name] do
124: pool.each do |k, v|
125: self.params[k.to_sym] = v
126: end
127: end
128: end
129: end130:```
Currently this cookbook uses the old method access for node attributes in five locations, this syntax has been removed in favour of the new bracket syntax in Chef 13.
Default www
pool configuration, installed with php-fpm package on Fedora 24, requires ACL enabled filesystem, but ACL not supported in docker (or at least in this particular image).
Removing default pool or changing listen
from socket to port would be quick solution, but...
Disabling www
pool thru attributes won't help, because it fails at installation step while pool can be disabled only at configuration step which follows. For the same reason overriding template won't help either.
If it would be possible to postpone starting the service untill after configuration step, that could possibly help...
Any ideas?
Because of this:
cookbook-php-fpm/recipes/configure.rb
Line 29 in 159a169
Chef now throws this error when attempting to load when no pool configuration is added:
Recipe Compile Error in /tmp/vagrant-chef/b5f2829f9f0d42b98697b1ee54f892ed/cookbooks/php-fpm/recipes/default.rb
Corey Peterson [3:05 PM]3:05
=> default: NoMethodError
==> default: -------------
==> default: undefined method `key?' for #<Chef::Node::ImmutableArray:0x000000021df248>
or 5.4?
Please update this section of the pool configuration:
;listen.owner = nobody
;listen.group = nobody
listen.mode = 0660
The mode recently changed from 0666 to 0660 which makes the web server no longer able to access the socket. Ideally all three parameters should be overridable attributes.
Thanks
When installing php5-fpm package, php5-cgi is unnecessary, it's not even used by FPM.
That may just be cruft from when FPM first came out, i dunno, but it's not relevant current-day.
Pointing this out, as your default recipe installs both php5-cgi and php5-fpm.
I'm updating value of start_servers parameter from override_attributes in my role. It is not updating that value.
Was getting this error: http://stackoverflow.com/questions/23443398/nginx-error-connect-to-php5-fpm-sock-failed-13-permission-denied
Solved it by doing:
php_fpm_pool 'www' do
listen_owner 'www-data'
listen_group 'www-data'
end
Since the user/group of the php fpm processes are already set to www-data
(https://github.com/yevgenko/cookbook-php-fpm/blob/master/attributes/default.rb#L10-L11), I think it would be great to also put listen.owner
and listen.group
to this as well to avoid this ugly bug!
I was getting the following error when trying to run the default recipe on an ec2 instance:
================================================================================
Recipe Compile Error in /var/chef/cache/cookbooks/mycookbook/recipes/site-mysite.com.rb
================================================================================
NameError
---------
Cannot find a resource for yum_key on amazon version 2013.09
Cookbook Trace:
---------------
/var/chef/cache/cookbooks/php-fpm/recipes/default.rb:82:in `from_file'
/var/chef/cache/cookbooks/mycookbook/recipes/site-mysite.com.rb:14:in `from_file'
Relevant File Content:
----------------------
/var/chef/cache/cookbooks/php-fpm/recipes/default.rb:
75: key "http://www.dotdeb.org/dotdeb.gpg"
76: action :add
77: end
78: end
79:
80: when 'amazon', 'fedora', 'centos', 'redhat'
81: unless platform?('centos', 'redhat') && node['platform_version'].to_f >= 6.4
82>> yum_key 'RPM-GPG-KEY-remi' do
83: url 'http://rpms.famillecollet.com/RPM-GPG-KEY-remi'
84: end
85:
86: yum_repository 'remi' do
87: description 'Remi'
88: url 'http://rpms.famillecollet.com/enterprise/$releasever/remi/$basearch/'
89: mirrorlist 'http://rpms.famillecollet.com/enterprise/$releasever/remi/mirror'
90: key 'RPM-GPG-KEY-remi'
91: action :add
The latest version of the yum cookbook has removed the yum_key resource, replaced with yum_globalconfig.
The php-fpm libraries are available in the amzn-main repository so it might not even be necessary to use Remi.
Can I use this cookbook without dotdeb repo? With deb from wheezy repo or myself?
When i'm trying to install php-fpm on Ubuntu 14.04 i get this error.
Using Bento Ubuntu-14.04 box.
* package[php5-fpm] action upgrade[2014-10-17T13:42:13+00:00] INFO: Processing package[php5-fpm] action upgrade (php-fpm::install line 33)
[2014-10-17T13:42:33+00:00] INFO: package[php5-fpm] upgraded from uninstalled to 5.5.9+dfsg-1ubuntu4.4
- upgrade package php5-fpm from uninstalled to 5.5.9+dfsg-1ubuntu4.4
* service[php-fpm] action enable[2014-10-17T13:42:33+00:00] INFO: Processing service[php-fpm] action enable (php-fpm::install line 48)
============================================================================= Error executing action `enable` on resource 'service[php-fpm]'
============================================================================
ArgumentError
-------------
invalid byte sequence in US-ASCII
Resource Declaration:
---------------------
# In /tmp/kitchen/cookbooks/php-fpm/recipes/install.rb
48: service "php-fpm" do
49: provider service_provider if service_provider
50: service_name php_fpm_service_name
51: supports :start => true, :stop => true, :restart => true, :reload => true
52: action [ :enable, :start ]
53: end
Compiled Resource:
------------------
# Declared in /tmp/kitchen/cookbooks/php-fpm/recipes/install.rb:48:in `from_file'
service("php-fpm") do
provider Chef::Provider::Service::Upstart
action [:enable, :start]
supports {:start=>true, :stop=>true, :restart=>true, :reload=>true}
retries 0
retry_delay 2
guard_interpreter :default
service_name "php5-fpm"
pattern "php-fpm"
cookbook_name :"php-fpm"
recipe_name "install"
end
It would be nice if it will be possible to configure pm.status_path via attributes or a pool definition lwrp. Cause right now status is just disabled and it is hardcoded.
When running chef exec rspec
I get the following output:
$ chef exec rspec
F
Failures:
1) TestPhpFpmCookbook::default When all attributes are default, on an Ubuntu 16.04 converges successfully
Failure/Error: expect { chef_run }.to_not raise_error
expected no Exception, got #<ChefSpec::Error::CommandNotStubbed: Executing a real command is disabled. Unregistered command:
...tub_command("test -d /etc/php/7.0/fpm/pool.d || mkdir -p /etc/php/7.0/fpm/pool.d").and_return(...)
> with backtrace:
# ./spec/unit/recipes/default_spec.rb:15:in `block (3 levels) in <top (required)>'
# ./spec/unit/recipes/default_spec.rb:19:in `block (4 levels) in <top (required)>'
# ./spec/unit/recipes/default_spec.rb:19:in `block (3 levels) in <top (required)>'
# ./spec/unit/recipes/default_spec.rb:19:in `block (3 levels) in <top (required)>'
Finished in 25.44 seconds (files took 20.13 seconds to load)
1 example, 1 failure
Failed examples:
rspec ./spec/unit/recipes/default_spec.rb:18 # TestPhpFpmCookbook::default When all attributes are default, on an Ubuntu 16.04 converges successfully
My version of ChefDK on macOS 10.12.4:
$ chef -v
Chef Development Kit Version: 1.3.43
chef-client version: 12.19.36
delivery version: master (dd319aa632c2f550c92a2172b9d1226478fea997)
berks version: 5.6.4
kitchen version: 1.16.0
I create the cookbook doing the following chef generate cookbook TestPhpFpmCookbook
. Everything is as generated unless mentioned below...
metadata.rb:
name 'TestPhpFpmCookbook'
maintainer 'The Authors'
maintainer_email '[email protected]'
license 'All Rights Reserved'
description 'Installs/Configures TestPhpFpmCookbook'
long_description 'Installs/Configures TestPhpFpmCookbook'
version '0.1.0'
chef_version '>= 12.1' if respond_to?(:chef_version)
depends 'php-fpm', '~> 0.7.9'
default.rb:
include_recipe 'php-fpm::default'
Moving from ubuntu 14.04 to 16.04 now the Vagrant provisioning of "recipe[php-fpm::default]" raise this exception:
Chef::Exceptions::Package: apt_package[php5-fpm] (php-fpm::install line 34) had an error: Chef::Exceptions::Package: No candidate version available for php5-fpm
If you need I can post the entire stacktrace.
Would you mind adding a CHANGELOG to the project so it's clear what changes in each version.
================================================================================
Error executing action `enable` on resource 'service[php-fpm]'
================================================================================
Mixlib::ShellOut::ShellCommandFailed
------------------------------------
Expected process to exit with [0], but received '1'
---- Begin output of /usr/sbin/update-rc.d -n -f php7.2-fpm remove ----
STDOUT:
STDERR: update-rc.d: error: unknown option
usage: update-rc.d [-f] <basename> remove
update-rc.d [-f] <basename> defaults
update-rc.d [-f] <basename> defaults-disabled
update-rc.d <basename> disable|enable [S|2|3|4|5]
-f: force
The disable|enable API is not stable and might change in the future.
---- End output of /usr/sbin/update-rc.d -n -f php7.2-fpm remove ----
Ran /usr/sbin/update-rc.d -n -f php7.2-fpm remove returned 1
Resource Declaration:
---------------------
# In /root/chef-solo/local-mode-cache/cache/cookbooks/php-fpm/recipes/install.rb
56: service 'php-fpm' do
57: provider service_provider if service_provider
58: service_name php_fpm_service_name
59: supports start: true, stop: true, restart: true, reload: true
60: action [:enable, :start]
61: end
Compiled Resource:
------------------
# Declared in /root/chef-solo/local-mode-cache/cache/cookbooks/php-fpm/recipes/install.rb:56:in `from_file'
service("php-fpm") do
provider Chef::Provider::Service::Debian
action [:enable, :start]
default_guard_interpreter :default
service_name "php7.2-fpm"
enabled nil
running nil
masked nil
pattern "php-fpm"
declared_type :service
cookbook_name "php-fpm"
recipe_name "install"
supports {:start=>true, :stop=>true, :restart=>true, :reload=>true}
end
System Info:
------------
chef_version=13.8.5
platform=ubuntu
platform_version=18.04
ruby=ruby 2.4.3p205 (2017-12-14 revision 61247) [x86_64-linux]
program_name=chef-solo worker: ppid=30645;start=23:48:10;
executable=/opt/chef/bin/chef-solo
STDOUT: Could not retrieve mirrorlist http://rpms.famillecollet.com/enterprise/latest/remi/mirror error was
14: PYCURL ERROR 22 - "The requested URL returned error: 404 Not Found"
STDERR: http://rpms.famillecollet.com/enterprise/latest/remi/x86_64/repodata/repomd.xml: [Errno 14] PYCURL ERROR 22 - "The requested URL returned error: 404 Not Found"
Trying other mirror.
[Thu, 20 Jun 2013 10:35:28 +0000] INFO: *** Chef 11.4.4 ***
[Thu, 20 Jun 2013 10:35:31 +0000] INFO: Setting the run_list to ["recipe[vagrant_main]"] from JSON
[Thu, 20 Jun 2013 10:35:31 +0000] INFO: Run List is [recipe[vagrant_main]]
[Thu, 20 Jun 2013 10:35:31 +0000] INFO: Run List expands to [vagrant_main]
[Thu, 20 Jun 2013 10:35:31 +0000] INFO: Starting Chef Run for debian.local
[Thu, 20 Jun 2013 10:35:31 +0000] INFO: Running start handlers
[Thu, 20 Jun 2013 10:35:31 +0000] INFO: Start handlers complete.
[Thu, 20 Jun 2013 10:35:32 +0000] INFO: Processing execute[apt-get update] action run (apt::default line 20)
[Thu, 20 Jun 2013 10:35:47 +0000] INFO: execute[apt-get update] ran successfully
Recipe Compile Error in /tmp/vagrant-chef-1/chef-solo-1/cookbooks/vagrant_main/recipes/default.rb
Chef::Exceptions::ImmutableAttributeModification
Node attributes are read-only when you do not specify which precedence level to set. To set an attribute use code like `node.default["key"] = "value"'
/tmp/vagrant-chef-1/chef-solo-1/cookbooks/php-fpm/recipes/default.rb:41:in from_file' /tmp/vagrant-chef-1/chef-solo-1/cookbooks/vagrant_main/recipes/default.rb:6:in
from_file'
/tmp/vagrant-chef-1/chef-solo-1/cookbooks/php-fpm/recipes/default.rb:
34: # FIXME: apt-get update didn't trigger in above
35: execute "apt-get update"
36: end
37: when 'debian'
38: # Configure Dotdeb repos
39: # TODO: move this to it's own 'dotdeb' cookbook?
40: # http://www.dotdeb.org/instructions/
41>> if node.lsb.codename = 'squeeze'
42: apt_repository "dotdeb" do
43: uri "http://packages.dotdeb.org"
44: distribution "squeeze"
45: components ['all']
46: key "http://www.dotdeb.org/dotdeb.gpg"
47: action :add
48: end
49: elsif node.platform_version.to_f >= 7.0
50: apt_repository "dotdeb" do
[Thu, 20 Jun 2013 10:35:47 +0000] ERROR: Running exception handlers
[Thu, 20 Jun 2013 10:35:47 +0000] ERROR: Exception handlers complete
[Thu, 20 Jun 2013 10:35:47 +0000] FATAL: Stacktrace dumped to /tmp/vagrant-chef-1/chef-stacktrace.out
[Thu, 20 Jun 2013 10:35:47 +0000] FATAL: Chef::Exceptions::ImmutableAttributeModification: Node attributes are read-only when you do not specify which precedence level to set. To set an attribute use code like `node.default["key"] = "value"'
Chef never successfully completed! Any errors should be visible in the
output above. Please fix your recipes so that they properly complete.
If I try with if node.lsb.codename == 'squeeze' works but another error appear
Is there a reason that php-fpm needs to restart on every chef run? On a default chef client/server install this will restart php-fpm every 30 minutes.
The relevant code:
https://github.com/yevgenko/cookbook-php-fpm/blob/master/recipes/default.rb#L116
Thanks for the great cookbook btw!
I have installed php-fpm via chef in vagrant using just "add_recipe 'php-fpm'". The basic install seems to work but the system fails when starting up the service. The error given is:
Starting php-fpm: [06-Dec-2013 07:40:51] ERROR: Unable to globalize '/etc/php-fpm.d/pools/*.conf' (ret=2) from /etc/php-fpm.conf at line 11.
[06-Dec-2013 07:40:51] ERROR: failed to load configuration file '/etc/php-fpm.conf'
[06-Dec-2013 07:40:51] ERROR: FPM initialization failed
I saw that the path of the include directive in php-fpm.conf is wrong, it is currently pointing to /etc/php-fpm.d/pools/*.conf
but there is no pools directory inside /etc/php-fpm.d/
. Changing the include path in the conf file to remote "/pools" allows the service to be started.
Can you please release the last changes to the chef-supermarket.
For now the official cookbook does not work with ubuntu18.04.
Cookbook php-fpm version 0.7.0 successfully installed
ERROR: IOError: Cannot open or read /home/chefclient/chef-repo/cookbooks/php-fpm/metadata.rb!
Download missing metadata.rb http://cookbooks.opscode.com/cookbooks/php-fpm/download
Re-release with stove to get a metadata.rb
Fix: Re-release with stove 3.2.2 to get a metadata.rb
seems you haven't pushed any tags to github repository.
https://github.com/yevgenko/cookbook-php-fpm/releases
if you need help, then i'm more than happy to guide
In attributes default.rb 'amazon' is not listed as platform_family option. This should be included as an alternative of 'rhel' or 'fedora' in order to properly define other attributes that are coupled to it.
I'm opening a PR because of this.
preferably MIT
But any of the GPL licenses would be fine too.
This needs to be configurable in the template. The default setting for cgi.fix_pathinfo in php-fpm is insecure.
https://www.digitalocean.com/community/articles/how-to-install-linux-nginx-mysql-php-lemp-stack-on-ubuntu-14-04 for more info.
The install recipe attempts to utilize upstart for versions of Ubuntu at 13.10 and beyond (see lines 44-46). I discovered that 15.04 does not ship with upstart enabled and instead uses systemd. I imagine this affects 15.10 as well but have not tested to confirm that. As a result, the following error manifests:
==> default: * service[php-fpm] action enable
==> default:
==> default:
==> default: ================================================================================
==> default: Error executing action enable
on resource 'service[php-fpm]'
==> default: ================================================================================
==> default:
==> default: Errno::ENOENT
==> default: -------------
==> default: No such file or directory - /sbin/status
I have resolved this in my environment by commenting out lines 44-46 but a proper fix would limit the range of utilizing upstart to versions of ubuntu where it ships as default (13.10 to 14.10 I believe).
Wondering if there's any reason we can't add status to default.rb - something like:
supports :start => true, :stop => true, :restart => true, :reload => true, :status => true
Using minitest-handler allows for an assertion like service("php5-fpm").must_be_running, which depends on status. Availability could vary by platform/version but on Ubuntu 12.04, the service does return status as expected.
Thanks,
Jason
This is for version 0.7.0.
The recipe php_fpm::configure uses a resource (actually, a definition) php_fpm_pool www that will unconditionally disable the www pool (and thus delete the www.conf file) even if the www pool is actually needed, and will be re-created in the next step.
This is a problem because, first, it makes this cookbook non-idempotent. Secondly, some tools (such as a nagios plugin) counts the number of updated resources, and produce a warning when too man resources are updated.
The easiest way to see this happening is in the default case: simply add php-fpm::default to your runlist.
* service[php-fpm]: Service is not known to chkconfig.
================================================================================
Error executing action `enable` on resource 'service[php-fpm]'
================================================================================
Let use a custom 'pool.conf.erb'. You are using a fixed name for this template in the definition 'php_fpm_pool.rb' and it would be great we could pass the name as an attribute even if there is a default name.
A declarative, efficient, and flexible JavaScript library for building user interfaces.
๐ Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. ๐๐๐
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google โค๏ธ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.