I am running a very similar set up (nginx 0.7.61, php+fpm 5.2.10) and my PHP processes never die, even after being idle.
The process control bits of my php-fpm.conf are as follows:
<value name="pm">
<value name="style">static</value>
<value name="max_children">3</value>
<value name="apache_like">
<value name="StartServers">20</value>
<value name="MinSpareServers">5</value>
<value name="MaxSpareServers">35</value>
</value>
</value>
<value name="request_terminate_timeout">0s</value>
<value name="request_slowlog_timeout">0s</value>
<value name="slowlog">logs/slow.log</value>
<value name="rlimit_files">1024</value>
<value name="rlimit_core">0</value>
<value name="chroot"></value>
<value name="chdir"></value>
<value name="catch_workers_output">yes</value>
<value name="max_requests">500</value>
Note that while I have the apache-like bits defined (they were part of the default config), they aren't used because I have PM style static set.
You can turn up the logs to debug level using this in the global options section:
<value name="log_level">debug</value>
to see if there's a reported reason that it's shutting down workers.
A latch-ditch fix if this doesn't work would be to have a service like pingdom hit a php on your site every x minutes, but my experience with this software combo doesn't suggest that this should be required.
Since you're getting the error Fatal error: Call to undefined function mysql_connect()
, that means that the MySQL extension is not being loaded by PHP. This is configured in your php.ini file.
To find the location of your php.ini file, create a php file and in it paste the following.
<?php phpinfo(); ?>
On the page (near the top) you will have an entry labelled Loaded Configuration File. Check this file that has been loaded is actually the one that you expect it to load. Personally, mine loads from C:/php/php.ini
, but if I recall correctly when I was initially setting it all up, it was trying to read from C:/Windows/php.ini
(which didn't exist) so was using defaults for everything, which didn't include some of the extra modules I wanted.
Open that file with your favourite text editor and in there should be several lines beginning extension=xxxxx.dll
.
Look through the list of modules and check that extension=php_mysql.dll
is listed and the first character of the line is not a semi-colon (;
). If it's not listed, just add it to the list - if it has the semi-colon at the beginning of the line, remove the semi-colon and save the file.
You should also check the value of extension_dir
, and also verify this path exists on the filesystem. This should be something similar to c:/php/ext
.
Once you've made changes to the php.ini file, you will need to restart Apache so the configuration file is re-read.
Once you've restarted Apache, refresh your phpinfo page and check that it has sections listed for MySQL.
You might also want to check if C:\php
is included in your PATH environment variable.
If you're still having issues, try firing up a command line and cd to C:\php and type php -v
. This will output the PHP version, but will often spit out more error messages than are shown when loading a web page
Best Answer
For anyone else with the same question:
don't recompile php5, only compile pcntl for your php version and move it to the php extension folder.