php.ini-找不到要编辑的正确文件

php.ini-找不到要编辑的正确文件

我正在努力适应最大执行时间内存限制指令。

phpinfo()输出:

Server API  FPM/FastCGI Virtual Directory Support   disabled
Configuration File (php.ini) Path   /etc/php/7.0/fpm Loaded
Configuration File  /etc/php/7.0/fpm/php.ini 
Scan this dir for additional .ini files /etc/php/7.0/fpm/conf.d

我已经更新了这两个指令

/etc/php/7.0/fpm/php.ini

并重新启动了 apache2,但没有成功。

php -r'打印 php_ini_loaded_file();print_r(php_ini_scanned_files());'输出:

/etc/php/7.0/cli/php.ini/
/etc/php/7.0/cli/conf.d/10-mysqlnd.ini,
/etc/php/7.0/cli/conf.d/10-opcache.ini,
/etc/php/7.0/cli/conf.d/10-pdo.ini,
/etc/php/7.0/cli/conf.d/15-xml.ini,
/etc/php/7.0/cli/conf.d/20-apcu.ini,
/etc/php/7.0/cli/conf.d/20-calendar.ini,
/etc/php/7.0/cli/conf.d/20-ctype.ini,
/etc/php/7.0/cli/conf.d/20-curl.ini,
/etc/php/7.0/cli/conf.d/20-dom.ini,
/etc/php/7.0/cli/conf.d/20-exif.ini,
/etc/php/7.0/cli/conf.d/20-fileinfo.ini,
/etc/php/7.0/cli/conf.d/20-ftp.ini,
/etc/php/7.0/cli/conf.d/20-gd.ini,
/etc/php/7.0/cli/conf.d/20-gettext.ini,
/etc/php/7.0/cli/conf.d/20-iconv.ini,
/etc/php/7.0/cli/conf.d/20-imagick.ini,
/etc/php/7.0/cli/conf.d/20-imap.ini,
/etc/php/7.0/cli/conf.d/20-intl.ini,
/etc/php/7.0/cli/conf.d/20-json.ini,
/etc/php/7.0/cli/conf.d/20-mbstring.ini,
/etc/php/7.0/cli/conf.d/20-mcrypt.ini,
/etc/php/7.0/cli/conf.d/20-memcache.ini,
/etc/php/7.0/cli/conf.d/20-mysqli.ini,
/etc/php/7.0/cli/conf.d/20-pdo_mysql.ini,
/etc/php/7.0/cli/conf.d/20-pdo_sqlite.ini,
/etc/php/7.0/cli/conf.d/20-phar.ini,
/etc/php/7.0/cli/conf.d/20-posix.ini,
/etc/php/7.0/cli/conf.d/20-pspell.ini,
/etc/php/7.0/cli/conf.d/20-readline.ini,
/etc/php/7.0/cli/conf.d/20-recode.ini,
/etc/php/7.0/cli/conf.d/20-shmop.ini,
/etc/php/7.0/cli/conf.d/20-simplexml.ini,
/etc/php/7.0/cli/conf.d/20-sockets.ini,
/etc/php/7.0/cli/conf.d/20-sqlite3.ini,
/etc/php/7.0/cli/conf.d/20-sysvmsg.ini,
/etc/php/7.0/cli/conf.d/20-sysvsem.ini,
/etc/php/7.0/cli/conf.d/20-sysvshm.ini,
/etc/php/7.0/cli/conf.d/20-tidy.ini,
/etc/php/7.0/cli/conf.d/20-tokenizer.ini,
/etc/php/7.0/cli/conf.d/20-wddx.ini,
/etc/php/7.0/cli/conf.d/20-xmlreader.ini,
/etc/php/7.0/cli/conf.d/20-xmlrpc.ini,
/etc/php/7.0/cli/conf.d/20-xmlwriter.ini,
/etc/php/7.0/cli/conf.d/20-xsl.ini,
/etc/php/7.0/cli/conf.d/20-zip.ini

php --ini输出:

Configuration File (php.ini) Path: /etc/php/7.0/cli
Loaded Configuration File:         /etc/php/7.0/cli/php.ini
Scan for additional .ini files in: /etc/php/7.0/cli/conf.d
Additional .ini files parsed:      /etc/php/7.0/cli/conf.d/10-mysqlnd.ini,

我已经更新了这两个指令

/etc/php/7.0/cli/php.ini/

并重新启动 apache2 但仍然没有运气。

查找/-type f-name“php.ini”输出:

/etc/php/7.0/cli/php.ini
/etc/php/7.0/cgi/php.ini
/etc/php/7.0/fpm/php.ini
/etc/php/7.0/apache2/php.ini

再次,我更新了所有 *.php.ini 文件中的两个指令,并重新启动了 apache2,但仍然phpinfo()显示旧设置。

知道我在这里做错了什么吗?

答案1

Php-fpm 独立于 Apache 运行,因此需要重新加载或重新启动才能看到新的指令。;-)

答案2

根据配置布局这似乎是一个基于 Debian 的系统。

对于每个major.minor版本M.N的 PHP(其中 M 为 7,N 为 0、1、...),每个 SAPI(apache2/cgi/fpm/cli/phpdbg/...)都有不同的中央配置文件 /etc/php/M.N/$SAPI/php.ini

根据phpinfo()Apache 的输出,使用 PHP FPM/FastCGI 作为服务器应用程序编程接口 (SAPI)。因此,使用中的配置文件/etc/php/7.0/fpm/。重新加载配置需要重新加载 PHP-FPM(与 Apache 分开):

sudo systemctl reload php7.0-fpm

从命令行使用 PHP 时,命令行接口被使用,相反,所以/etc/php/7.0/cli/正在使用。启动命令时,PHP CLI 会读取配置。这就是您用于测试的命令给出相互矛盾的结果的原因。

相关内容