# Apache with PHP-FPM intermittent error

## NathanZachary

So, I've been running Apache without mod_php in favour of PHP-FPM connected via proxy_fcgi (UDS) for quite some time now.  Seemingly randomly, though, there are some times where performing any function on a site (from updating it, to just browsing, to loading some Piwik stats) will result in a "503 Service Unavailable" error.  When that happens, I see the following snippet in the Apache error_log:

```

[Mon Oct 17 20:42:01.829980 2016] [proxy_fcgi:error] [pid 2105:tid 140190332966656] [client IP:56535] AH01067: Failed to read FastCGI header, referer: http://site1/wp-admin/theme-editor.php?<snip>

[Mon Oct 17 20:42:01.830077 2016] [proxy_fcgi:error] [pid 2105:tid 140190332966656] (104)Connection reset by peer: [client IP:56535] AH01075: Error dispatching request to : , referer: http://site1/wp-admin/theme-editor.php?<snip>

```

At the same time, I see the following notices and warnings in the PHP-FPM log:

```

[17-Oct-2016 20:42:01] WARNING: [pool site1] child 15811, script '<snip>site1/wp/htdocs/wp-admin/theme-editor.php' (request: "GET /wp-admin/theme-editor.php") execution timed out (1432.230967 sec), terminating

[17-Oct-2016 20:42:01] WARNING: [pool site1] child 15811 exited on signal 15 (SIGTERM) after 14016.074704 seconds from start

[17-Oct-2016 20:42:01] NOTICE: [pool site1] child 23195 started

```

I have looked up these errors, but can't seem to find a cause of them.  Here is the relevant configuration for the given site:

Apache's UDS proxy to PHP:

```

        <FilesMatch "\.php$">

                SetHandler "proxy:unix:///var/run/php-fpm/site1.sock|fcgi://site1/"

        </FilesMatch>

        <Proxy fcgi://site1/ enablereuse=on max=10>

        </Proxy>

```

PHP-FPM:

```

[site1]

listen = /var/run/php-fpm/site1.sock

listen.owner = site1

listen.group = apache

listen.mode = 0660

user = site1

group = apache

pm = dynamic

pm.start_servers = 3

pm.max_children = 100

pm.min_spare_servers = 2

pm.max_spare_servers = 5

pm.max_requests = 10000

request_terminate_timeout = 300

```

I thought that it might have something to do with PHP's OpCache, so I disabled it, but the problem still comes up from time to time.

Any pointers?

Thank you preemptively.

Cheers,

Nathan Zachary

----------

