使用PHP-FPM时,我可以覆盖htaccess中的PHP设置吗?

我的vhost看起来像这样:

<Directory "/var/www">
  Options Indexes FollowSymlinks MultiViews
  AllowOverride All
  Require all granted

  <FilesMatch "\.php$">
    Require all granted
    SetHandler proxy:fcgi://127.0.0.1:9000
  </FilesMatch>
</Directory>

我正在尝试将php_value行添加到我的.htaccess文件中.在我这样做的时候,我得到500个错误,这在我的Apache的错误日志中:

/var/www/.htaccess: Invalid command ‘php_value’, perhaps misspelled or
defined by a module not included in the server configuration

所以,问题是:当使用PHP-FPM时,有没有办法通过.htaccess覆盖php.ini设置?

TIA.

解决方法:

正如其他人已经指出的那样,不能,在使用PHP-FPM时,不能通过.htaccess覆盖设置.

但似乎有一种类似PHP的机制,名为.user.ini文件.

Since PHP 5.3.0, PHP includes support for configuration INI files on a per-directory basis. These files are processed only by the CGI/FastCGI SAPI. This functionality obsoletes the PECL htscanner extension. If you are using Apache, use .htaccess files for the same effect.

In addition to the main php.ini file, PHP scans for INI files in each directory, starting with the directory of the requested PHP file, and working its way up to the current document root (as set in $_SERVER[‘DOCUMENT_ROOT’]). In case the PHP file is outside the document root, only its directory is scanned.

Only INI settings with the modes PHP_INI_PERDIR and PHP_INI_USER will be recognized in .user.ini-style INI files.

并在下面的评论中

“If you are using Apache, use .htaccess files for the same effect.”

To clarify, this applies only to Apache module mode. If you put php directives in .htaccess on an Apache CGI/FastCGI server, this will bomb the server out with a 500 error.

因此,您可以创建类似于.htaccess的.user.ini文件,但采用的是ini样式格式.

上一篇:php-使用301重定向仅重定向WordPress主页


下一篇:如何在png / jpg扩展中运行php脚本