My vhost looks like this:
<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>
I'm trying to add php_value lines to my .htaccess file. As soon as I do, I get 500 errors, and this in my Apache's errors log:
/var/www/.htaccess: Invalid command 'php_value', perhaps misspelled or defined by a module not included in the server configuration
So, the question: Is there any way to override php.ini settings via .htaccess, when using PHP-FPM?
tia.
fpm/php. ini will be used when PHP is run as FPM -- which is the case with an nginx installation. And you can check that calling phpinfo() from a php page served by your webserver.
By default Apache will use mod_php so now you can configure Apache to use PHP-FPM.
htaccess using PHP's built-in webserver (it is not relying on apache, it is implemented entirely in PHP's core).
Conclusion. PHP-FPM is an efficient method on how to minimize the memory consumption and rise the performance for the websites with heavy traffic. It is significantly faster than traditional CGI-based methods in multi-user PHP environments.
As others already pointed out, no, you can't override settings via .htaccess when using PHP-FPM.
But there seems to be a similar mechanism from PHP, named .user.ini
files.
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.
And in a comment below
"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.
So you can create .user.ini
files analogue to .htaccess, but in ini style format.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With