我在 /var/www/html/nextcloud 中有以下文件 .user.ini
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
但被忽视了,
我收到错误:
"Zend OPcache can't be temporary enabled (it may be only disabled till the end of request) at Unknown#0"
这是 php-fpm 信息的一部分:
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
软件版本:
[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
我是不是漏掉了什么?为什么它被忽略了?
答案1
根据 PHP 文档设置,只有可更改模式 PHP_INI_PERDIR 和 PHP_INI_USER 才能在 .user.ini 文件中被识别。opcache.enable 具有模式 PHP_INI_ALL,因此它在 .user.ini 文件中不起作用。您可能想看看这个讨论如何正确使用 opcache 的其他帖子。 https://stackoverflow.com/questions/21556437/disable-opcache-temporarily
如果您正在使用 nextcloud,我想您应该看看。 https://help.nextcloud.com/t/use-htaccess-user-ini-for-all-nextcloud-related-php-configuration/18492