From 4e0412adb2eafeb71122b2f41c12b4bf2d138ed7 Mon Sep 17 00:00:00 2001 From: Julien Moutinho Date: Tue, 24 Sep 2013 13:06:04 +0200 Subject: [PATCH] Correction : php5-fpm & MySQL : is not a valid MySQL-Link resource. NOTE: fix things like this : Warning: mysql_select_db(): 2 is not a valid MySQL-Link resource in test.php which is likely due to php5-fpm not correctly destroying all PHP variables ; uses auto_prepend_file in php.ini : - works when script ends or exit() is called; - works when mysql.so is loaded or not; - not sure if this works with multiple MySQL connexions. --- etc/php5/fpm/auto_prepend_file.php | 14 ++++++++++++++ etc/php5/fpm/php.ini | 10 +++++----- etc/php5/fpm/pool.d/lhc_wiklou/php-fpm.conf | 2 +- etc/php5/fpm/pool.d/lhc_www/php-fpm.conf | 2 +- etc/php5/fpm/pool.d/ptitvelo_www/php-fpm.conf | 2 +- etc/sv/php5-fpm/local.sh | 3 +++ 6 files changed, 25 insertions(+), 8 deletions(-) create mode 100644 etc/php5/fpm/auto_prepend_file.php diff --git a/etc/php5/fpm/auto_prepend_file.php b/etc/php5/fpm/auto_prepend_file.php new file mode 100644 index 0000000..d44bad0 --- /dev/null +++ b/etc/php5/fpm/auto_prepend_file.php @@ -0,0 +1,14 @@ + diff --git a/etc/php5/fpm/php.ini b/etc/php5/fpm/php.ini index d09d85f..6da720c 100644 --- a/etc/php5/fpm/php.ini +++ b/etc/php5/fpm/php.ini @@ -61,7 +61,7 @@ smtp_port = 25 [mbstring] [mcrypt] [MSSQL] -mssql.allow_persistent = On +mssql.allow_persistent = Off mssql.compatability_mode = Off mssql.max_links = -1 mssql.max_persistent = -1 @@ -70,7 +70,7 @@ mssql.min_message_severity = 10 mssql.secure_connection = Off [MySQL] mysql.allow_local_infile = On -mysql.allow_persistent = On +mysql.allow_persistent = Off mysql.cache_size = 2000 mysql.connect_timeout = 60 mysql.default_host = @@ -79,10 +79,10 @@ mysql.default_port = mysql.default_socket = /run/mysqld/sock/mysql mysql.default_user = mysql.max_links = -1 -mysql.max_persistent = -1 +mysql.max_persistent = 0 mysql.trace_mode = On [MySQLi] -mysqli.allow_persistent = On +mysqli.allow_persistent = Off mysqli.cache_size = 2000 mysqli.default_host = mysqli.default_port = 3306 @@ -111,7 +111,7 @@ allow_url_include = Off asp_tags = Off auto_append_file = auto_globals_jit = On -auto_prepend_file = +auto_prepend_file = /etc/php5/fpm/auto_prepend_file.php default_charset = "UTF-8" ; DEFAULT: default_mimetype = "text/html" diff --git a/etc/php5/fpm/pool.d/lhc_wiklou/php-fpm.conf b/etc/php5/fpm/pool.d/lhc_wiklou/php-fpm.conf index 3817323..01f6696 100644 --- a/etc/php5/fpm/pool.d/lhc_wiklou/php-fpm.conf +++ b/etc/php5/fpm/pool.d/lhc_wiklou/php-fpm.conf @@ -1,7 +1,7 @@ #php_admin_value[extension] = pdo_mysql.so php_admin_value[extension] = mysql.so pm.max_children = 15 -pm.max_requests = 200 +pm.max_requests = 1000 pm.max_spare_servers = 5 pm.min_spare_servers = 1 pm.process_idle_timeout = 60s diff --git a/etc/php5/fpm/pool.d/lhc_www/php-fpm.conf b/etc/php5/fpm/pool.d/lhc_www/php-fpm.conf index 04813ff..0064260 100644 --- a/etc/php5/fpm/pool.d/lhc_www/php-fpm.conf +++ b/etc/php5/fpm/pool.d/lhc_www/php-fpm.conf @@ -1,7 +1,7 @@ #php_admin_value[extension] = pdo_mysql.so php_admin_value[extension] = mysql.so pm.max_children = 4 -pm.max_requests = 1 +pm.max_requests = 1000 pm.max_spare_servers = 4 pm.min_spare_servers = 2 pm.process_idle_timeout = 60s diff --git a/etc/php5/fpm/pool.d/ptitvelo_www/php-fpm.conf b/etc/php5/fpm/pool.d/ptitvelo_www/php-fpm.conf index 04813ff..0064260 100644 --- a/etc/php5/fpm/pool.d/ptitvelo_www/php-fpm.conf +++ b/etc/php5/fpm/pool.d/ptitvelo_www/php-fpm.conf @@ -1,7 +1,7 @@ #php_admin_value[extension] = pdo_mysql.so php_admin_value[extension] = mysql.so pm.max_children = 4 -pm.max_requests = 1 +pm.max_requests = 1000 pm.max_spare_servers = 4 pm.min_spare_servers = 2 pm.process_idle_timeout = 60s diff --git a/etc/sv/php5-fpm/local.sh b/etc/sv/php5-fpm/local.sh index 5d99315..94fbab9 100644 --- a/etc/sv/php5-fpm/local.sh +++ b/etc/sv/php5-fpm/local.sh @@ -29,6 +29,9 @@ sudo install -m 440 -o php5 -g php5 \ sudo install -m 664 -o php5 -g php5 \ "$tool"/etc/php5/fpm/php.ini \ /etc/php5/fpm/php.ini +sudo install -m 664 -o php5 -g php5 \ + "$tool"/etc/php5/fpm/auto_prepend_file.php \ + /etc/php5/fpm/auto_prepend_file.php for conf in $( test ! -d "$tool"/etc/php5/fpm/conf.d || find "$tool"/etc/php5/fpm/conf.d \ -- 2.20.1