php .user.ini 未在 PHP FPM 安装中加载

php .user.ini 未在 PHP FPM 安装中加载

我正在使用 Ninja 防火墙管理自托管的 WordPress 网站。

为了让 Ninja 实现完整的 WAP 保护,我必须在根目录下的文件auto_prepend_file中添加一些配置。.user.ini

实际上,Ninja 会为您完成这项工作,而且我检查了文件(/var/www/mysite/.user.ini),它看起来不错。

我也检查了我的php.ini档案。

我正在使用 PHP FPM 7.3,其中包含以下几行。我做错了什么?

;;;;;;;;;;;;;;;;;;;;
; php.ini Options  ;
;;;;;;;;;;;;;;;;;;;;
; Name for user-defined php.ini (.htaccess) files. Default is ".user.ini"
user_ini.filename = ".user.ini"

; To disable this feature set this option to an empty value
;user_ini.filename =

; TTL for user-defined php.ini files (time-to-live) in seconds. Default is 300 $
;user_ini.cache_ttl = 300

但是当我查看我已加载的配置时,user.ini 文件未被加载:

Server API  FPM/FastCGI
Virtual Directory Support   disabled
Configuration File (php.ini) Path   /etc/php/7.3/fpm
Loaded Configuration File   /etc/php/7.3/fpm/php.ini
Scan this dir for additional .ini files     /etc/php/7.3/fpm/conf.d
Additional .ini files parsed    /etc/php/7.3/fpm/conf.d/10-mysqlnd.ini, /etc/php/7.3/fpm/conf.d/10-opcache.ini, /etc/php/7.3/fpm/conf.d/10-pdo.ini, /etc/php/7.3/fpm/conf.d/15-xml.ini, /etc/php/7.3/fpm/conf.d/20-bcmath.ini, /etc/php/7.3/fpm/conf.d/20-bz2.ini, /etc/php/7.3/fpm/conf.d/20-calendar.ini, /etc/php/7.3/fpm/conf.d/20-ctype.ini, /etc/php/7.3/fpm/conf.d/20-curl.ini, /etc/php/7.3/fpm/conf.d/20-dom.ini, /etc/php/7.3/fpm/conf.d/20-exif.ini, /etc/php/7.3/fpm/conf.d/20-fileinfo.ini, /etc/php/7.3/fpm/conf.d/20-ftp.ini, /etc/php/7.3/fpm/conf.d/20-gd.ini, /etc/php/7.3/fpm/conf.d/20-gettext.ini, /etc/php/7.3/fpm/conf.d/20-iconv.ini, /etc/php/7.3/fpm/conf.d/20-igbinary.ini, /etc/php/7.3/fpm/conf.d/20-imagick.ini, /etc/php/7.3/fpm/conf.d/20-intl.ini, /etc/php/7.3/fpm/conf.d/20-json.ini, /etc/php/7.3/fpm/conf.d/20-mbstring.ini, /etc/php/7.3/fpm/conf.d/20-mysqli.ini, /etc/php/7.3/fpm/conf.d/20-pdo_mysql.ini, /etc/php/7.3/fpm/conf.d/20-pdo_sqlite.ini, /etc/php/7.3/fpm/conf.d/20-phar.ini, /etc/php/7.3/fpm/conf.d/20-posix.ini, /etc/php/7.3/fpm/conf.d/20-readline.ini, /etc/php/7.3/fpm/conf.d/20-redis.ini, /etc/php/7.3/fpm/conf.d/20-shmop.ini, /etc/php/7.3/fpm/conf.d/20-simplexml.ini, /etc/php/7.3/fpm/conf.d/20-smbclient.ini, /etc/php/7.3/fpm/conf.d/20-sockets.ini, /etc/php/7.3/fpm/conf.d/20-sqlite3.ini, /etc/php/7.3/fpm/conf.d/20-sysvmsg.ini, /etc/php/7.3/fpm/conf.d/20-sysvsem.ini, /etc/php/7.3/fpm/conf.d/20-sysvshm.ini, /etc/php/7.3/fpm/conf.d/20-tidy.ini, /etc/php/7.3/fpm/conf.d/20-tokenizer.ini, /etc/php/7.3/fpm/conf.d/20-wddx.ini, /etc/php/7.3/fpm/conf.d/20-xmlreader.ini, /etc/php/7.3/fpm/conf.d/20-xmlwriter.ini, /etc/php/7.3/fpm/conf.d/20-xsl.ini, /etc/php/7.3/fpm/conf.d/20-zip.ini, /etc/php/7.3/fpm/conf.d/90-ncp.ini 

答案1

解决了!

目录中有一个 ini 文件/etc/php/7.3/fpm/conf.d正在将其重置user_ini.filename为空值。

如果您遇到同样的问题,在 Linux 上检测此问题的简单方法是运行此 grep 命令:

grep -R user_ini.filename /etc/php/7.3

检查是否有如下一行:

/etc/php/7.3/fpm/conf.d/90-ncp.ini:user_ini.filename =

然后编辑文件并用分号注释该行。

相关内容