Without the following patch on the php-fpm package, it is not possible to start nginx with aegir:

diff --git a/php5/fpm/pool.d/www.conf b/php5/fpm/pool.d/www.conf
index 28a0651..e6d552d 100644
--- a/php5/fpm/pool.d/www.conf
+++ b/php5/fpm/pool.d/www.conf
@@ -30,7 +30,8 @@ group = www-data
 ;                            specific port;
 ;   '/path/to/unix/socket' - to listen on a unix socket.
 ; Note: This value is mandatory.
-listen = /var/run/php5-fpm.sock
+;listen = /var/run/php5-fpm.sock
+listen = localhost:9000

 ; Set listen(2) backlog.
 ; Default Value: 128 (-1 on FreeBSD and OpenBSD)

Any idea on how this could be fixed?

Comments

omega8cc’s picture

What OS version are you using and how are you installing php5-fpm? By default it listens on port 9000 and doesn't use socket (which is less reliable, btw).

I have tested it both on Debian Squeeze using Dotdeb repo (there is no php5-fpm in the Debian Squeeze by default) and just a minute ago tested it also on Ubuntu Precise - it installs php5-fpm by default listening on 127.0.0.1:9000.

omega8cc’s picture

Status: Active » Postponed (maintainer needs more info)
anarcat’s picture

Status: Postponed (maintainer needs more info) » Active

Debian Wheezy and sid. php5-fpm 5.4.4~rc2-1

omega8cc’s picture

Title: default nginx config doesn't talk to the default php-fpm config » default nginx config doesn't talk to the default php-fpm config in Debian Wheezy and sid

So this is some new standard in the upcoming/next Debian release? If yes, then it is really weird, as it is against already used standard in all known Debian and Ubuntu (official and latest) releases.

In this case it is probably a docs/FAQ candidate, as we should continue to support the old standard with 127.0.0.1:9000.

We could also check (as we do with Nginx built-in, or not, modules) if there is php5-fpm listening on the default port or available via socket and adjust configuration using separate copy of the include file, but I really don't like adding yet another moving part, so not sure if we want this.

anarcat’s picture

php5-fpm entered Debian only in the Wheezy release (http://packages.debian.org/php5-fpm) so I do not see why i can be considered as being a standard here. Various guides recommend various things here and there on the web, (this one recommends :9000, while this one uses the socket).

Now, I noticed the upstream sample configuration file (sapi/fpm/php-fpm.conf.in in php 5.4) has 127.0.0.1:9000 as an example, so this seems to be a good guide. What i am saying here is that we should strive to have this a smooth experience that doesn't require people to edit system configuration files needlessly. For example, we should probably file a bug with the debian package.

I'll see if I can do this, but in the meantime we should certainly fix the install documentation to tell users to change that, because it's certainly weird.

anarcat’s picture

Note that the socket configuration was adopted both in Debian and Ubuntu following this bug report: http://bugs.debian.org/cgi-bin/bugreport.cgi?bug=650204

I have opened a separate bug report to revert this change back, we'll see how it goes.

anarcat’s picture

Here's the bug report: http://bugs.debian.org/682168

anarcat’s picture

Just a quick note to mention that ars technica describe using UNIX sockets as being "a lot faster" than network sockets:

http://arstechnica.com/information-technology/2012/12/web-served-part-3-...

omega8cc’s picture

Yes, sockets are a bit faster, but also less reliable, especially under load. The "a lot faster" sounds nice, but where are the benchmarks like this or this?

Some people say for example: "UNIX domain sockets are slightly faster than TCP sockets". Others say also that "Unix sockets are faster, but fall over at high load".

anarcat’s picture

Cool, thanks for the benchmarks, it was also my understanding that UNIX sockets were only marginally faster than TCP sockets. My initial feeling was based on this comment on MySQL:

For a connection from a client to a server running on the same host, if you connect using TCP/IP rather than a Unix socket file, performance is 7.5% slower. (On Unix, if you connect to the host name localhost, MySQL uses a socket file by default.)

(Source: https://dev.mysql.com/doc/refman/5.1/en/compile-and-link-options.html)

Now this is MySQL mind you, which may have strange code path issues. I was kind of surprised of arstechnica's article, and just wanted to share that, I also feel it's okay to default to TCP sockets, especially since it can enable us to migrate the PHP process pool to a completely different server.

omega8cc’s picture

Component: Code » HTTP Service
Category: bug » feature
Status: Active » Needs work

While I consider this move (both on Ubuntu and Debian) to use sockets by default as something really silly (because php-fpm sockets are unreliable) we probably should accept this as a fact in the next LTS releases, so we need an automated switch on the config level to stay backward compatible. Which is just another moving part.

anarcat’s picture

Category: feature » bug

It's rather unfortunate that my bug report on the debian package (http://bugs.debian.org/682168) has been ignored - but oh well. :) I agree that we need to fix this so that it works out of the box.. Maybe hostmaster-install or the debian-package should make an override?

How should we override this cleanly?

omega8cc’s picture

We should test/discover if PHP-FPM has been installed/running in the UNIX sockets or TCP mode and then use appropriate config. This means that we will need to print different config snippets also in the config includes, as we do already in the main config and in vhosts. Next, what if PHP-FPM doesn't run on install, at least when we are trying to determine its mode? This gets a bit complicated, but I will try to find some sane method. This should be done in Provision in the same way all other on the fly adjustments are done, like for checking Nginx version or path to init scripts or the binary itself etc.

anarcat’s picture

Okay that makes sense - i believe that if we run in server verify, that should give enough time for the fpm package to get configured and open up its ports. Then if you change that config and just reverify the server, it will catchup so it also covers changing from unix to tcp sockets...

omega8cc’s picture

This is not ready. We still assume that PHP-FPM is listening on port 9000.

omega8cc’s picture

So this is only Wheezy specific, because Precise listens on port 9000 on default php5-fpm install.

omega8cc’s picture

Status: Needs work » Fixed

OK, this commit does the trick: http://drupalcode.org/project/provision.git/commit/2d4a4c9 as long as the php5-fpm socket path is Wheezy default: /var/run/php5-fpm.sock

anarcat’s picture

good job!

Status: Fixed » Closed (fixed)

Automatically closed -- issue fixed for 2 weeks with no activity.

  • Commit 2d4a4c9 on dev-drupal-8, 6.x-2.x, dev-ssl-ip-allocation-refactor, 7.x-3.x, dev-subdir-multiserver, 6.x-2.x-backports, dev-helmo-3.x by omega8cc:
    Issue #1635622 by anarcat - Default nginx config doesn't talk to the...