Php-fpm ignores file .user.ini

php-fpmphp.ini

I have the following file .user.ini in /var/www/html/nextcloud

upload_max_filesize=511M
post_max_size=511M
memory_limit=512M
mbstring.func_overload=0
always_populate_raw_post_data=-1
default_charset='UTF-8'
output_buffering=0
opcache.enable=1
opcache.enable_cli=1
opcache.interned_strings_buffer=8
opcache.max_accelerated_files=10000
opcache.memory_consumption=128
opcache.save_comments=1
opcache.revalidate_freq=1
apc.enabled=1

But is ignored,

I get the error:

"Zend OPcache can't be temporary enabled (it may be only disabled till the end of request) at Unknown#0"

This is part of php-fpm info:

php-fpm  -i | grep SERVER | grep -v COLOR

R
$_SERVER['MANPATH'] => /opt/rh/rh-php71/root/usr/share/man:/opt/rh/rh-mariadb102/root/usr/share/man:/opt/rh/httpd24/root/usr/share/man:
$_SERVER['XDG_SESSION_ID'] => 4
$_SERVER['HOSTNAME'] => localhost.localdomain
$_SERVER['TERM'] => xterm-256color
$_SERVER['SHELL'] => /bin/bash
$_SERVER['HISTSIZE'] => 1000
$_SERVER['LIBRARY_PATH'] => /opt/rh/rh-mariadb102/root/usr/lib64:/opt/rh/httpd24/root/usr/lib64
$_SERVER['X_SCLS'] => httpd24 rh-mariadb102 rh-php71 
$_SERVER['JAVACONFDIRS'] => /etc/opt/rh/rh-mariadb102/java
$_SERVER['USER'] => root
$_SERVER['LD_LIBRARY_PATH'] => /opt/rh/rh-php71/root/usr/lib64:/opt/rh/rh-mariadb102/root/usr/lib64:/opt/rh/httpd24/root/usr/lib64
$_SERVER['CPATH'] => /opt/rh/rh-mariadb102/root/usr/include
$_SERVER['XDG_CONFIG_DIRS'] => /etc/opt/rh/rh-mariadb102/xdg:/etc/xdg
$_SERVER['PATH'] => /opt/rh/rh-php71/root/usr/bin:/opt/rh/rh-php71/root/usr/sbin:/opt/rh/rh-mariadb102/root/usr/bin:/opt/rh/rh-mariadb102/root/usr/sbin:/opt/rh/httpd24/root/usr/bin:/opt/rh/httpd24/root/usr/sbin:/usr/local/sbin:/usr/local/bin:/sbin:/bin:/usr/sbin:/usr/bin:/root/bin
$_SERVER['MAIL'] => /var/spool/mail/root
$_SERVER['PWD'] => /var/www/html/nextcloud
$_SERVER['LANG'] => es_AR.UTF-8
$_SERVER['HISTCONTROL'] => ignoredups
$_SERVER['HOME'] => /root
$_SERVER['SHLVL'] => 4
$_SERVER['LOGNAME'] => root
$_SERVER['XDG_DATA_DIRS'] => /opt/rh/rh-mariadb102/root/usr/share:/usr/local/share:/usr/share
$_SERVER['LESSOPEN'] => ||/usr/bin/lesspipe.sh %s
$_SERVER['PKG_CONFIG_PATH'] => /opt/rh/rh-mariadb102/root/usr/lib64/pkgconfig:/opt/rh/httpd24/root/usr/lib64/pkgconfig
$_SERVER['_'] => /opt/rh/rh-php71/root/usr/sbin/php-fpm
$_SERVER['PHP_SELF'] => 
$_SERVER['REQUEST_TIME_FLOAT'] => 1528984913.253
$_SERVER['REQUEST_TIME'] => 1528984913

Software versions:

[root@localhost nextcloud]# httpd -v
Server version: Apache/2.4.27 (Red Hat)
Server built:   Oct 26 2017 05:07:33
[root@localhost nextcloud]# php -v
PHP 7.1.8 (cli) (built: Aug  9 2017 13:20:06) ( NTS )
Copyright (c) 1997-2017 The PHP Group
Zend Engine v3.1.0, Copyright (c) 1998-2017 Zend Technologies
    with Zend OPcache v7.1.8, Copyright (c) 1999-2017, by Zend Technologies
[root@localhost nextcloud]# php-fpm -v
PHP 7.1.8 (fpm-fcgi) (built: Aug  9 2017 13:21:53)
Copyright (c) 1997-2017 The PHP Group
Zend Engine v3.1.0, Copyright (c) 1998-2017 Zend Technologies
    with Zend OPcache v7.1.8, Copyright (c) 1999-2017, by Zend Technologies    

Am I missing something? Why is it ignored?

Best Answer

As per the PHP documentation settings only with the changable mode PHP_INI_PERDIR and PHP_INI_USER can be recognized in .user.ini files. opcache.enable has mode PHP_INI_ALL so it won't work in .user.ini file. You might want to take look at this other thread discussing about correct use of opcache. https://stackoverflow.com/questions/21556437/disable-opcache-temporarily

If you are using nextcloud, I guess you should take a look at. https://help.nextcloud.com/t/use-htaccess-user-ini-for-all-nextcloud-related-php-configuration/18492

Related Topic