fix for configuring php-fpm like php on f27
authorparmentelat <thierry.parmentelat@inria.fr>
Thu, 8 Mar 2018 12:08:38 +0000 (13:08 +0100)
committerparmentelat <thierry.parmentelat@inria.fr>
Thu, 8 Mar 2018 12:08:38 +0000 (13:08 +0100)
plc.d/httpd

index ae0d4ed..572176d 100755 (executable)
@@ -21,6 +21,8 @@ php_ini=/etc/php.ini
 httpd_conf=/etc/httpd/conf/httpd.conf
 ssl_conf=/etc/httpd/conf.d/ssl.conf
 plc_conf=/etc/httpd/conf.d/plc.conf
+php_fpm_conf=/etc/php-fpm.d/plc.conf
+php_fpm_dir=$(dirname $php_fpm_conf)
 
 function disable_file () {
     file=$1; shift
@@ -71,6 +73,27 @@ case "$1" in
            sed -i -e 's,^short_open_tag = Off,short_open_tag = On,' $php_ini
        fi
 
+       ## patch php.ini
+       # memory limit
+       sed -i -e 's,^memory_limit = 32M *;,memory_limit = 80M ; patch myplc -- ,' $php_ini 
+       # log_errors : is On by default
+       # error_log
+       if ! grep '^error_log *=' $php_ini > /dev/null ; then
+         echo 'error_log = /var/log/php.log' >> $php_ini
+         touch /var/log/php.log
+         chmod 666 /var/log/php.log
+       fi
+
+        # configure php-fpm as well if present (starting with f27)
+        [ -d $php_fpm_dir ] && cat > $php_fpm_conf << EOF
+[www]
+php_value[include_path] = $include_path
+php_value[open_basedir] = $open_basedir
+php_value[date.timezone] = GMT
+php_value[short_open_tag] = On
+php_value[memory_limit] = 80M
+EOF
+
        # Disable default Listen directive
        sed -i -e '/^Listen/d' $httpd_conf
 
@@ -281,17 +304,6 @@ define('PLANETLAB_SUPPORT_EMAIL_ONLY', PLC_MAIL_SUPPORT_ADDRESS);
 ?>
 EOF
 
-       ## patch php.ini
-       # memory limit
-       sed -i -e 's,^memory_limit = 32M *;,memory_limit = 80M ; patch myplc -- ,' $php_ini 
-       # log_errors : is On by default
-       # error_log
-       if ! grep '^error_log *=' $php_ini > /dev/null ; then
-         echo 'error_log = /var/log/php.log' >> $php_ini
-         touch /var/log/php.log
-         chmod 666 /var/log/php.log
-       fi
-
        ## make room for logs
        touch /var/log/plcapi.log
        chmod 666 /var/log/plcapi.log