Arquivos .user.ini
O PHP oferece suporte a arquivos de configuração INI por diretório.
Esses arquivos são processados somente pelo SAPI
CGI/FastCGI. Essa funcionalidade substitui a extensão PECL htscanner.
Se o PHP estiver sendo executado como módulo do Apache, use arquivos .htaccess para o mesmo
efeito.
Além do arquivo principal php.ini, o PHP procura arquivos INI em cada
diretório, começando pelo diretório do arquivo PHP solicitado e
subindo até a raiz atual dos documentos (conforme definida em
$_SERVER['DOCUMENT_ROOT']). Se o arquivo PHP estiver
fora da raiz dos documentos, somente o diretório dele será examinado.
Somente configurações INI com os modos
INI_ALL, INI_PERDIR e
INI_USER serão reconhecidas nos arquivos INI do tipo
.user.ini.
Duas novas diretivas INI,
user_ini.filename and
user_ini.cache_ttl
controlam o uso de arquivos INI de usuário.
user_ini.filename define o nome do arquivo que o PHP procura
em cada diretório; se for definida como uma string vazia, o PHP não fará a varredura. O
padrão é .user.ini.
user_ini.cache_ttl controla a frequência de releitura dos arquivos INI de usuário.
O padrão é 300 segundos (5 minutos).
philsward at gmail dot com ¶13 years ago
If you have no idea what "PHP_INI_PERDIR" or "PHP_INI_USER" are or how they relate to setting a .user.ini file, take a look at the ini.list page: http://www.php.net/manual/en/ini.list.php
Basically, anything in the "Changeable" column labeled as PHP_INI_SYSTEM can't be set in the .user.ini file (so quit trying). It can ONLY be set at the main php.ini level.
Anonymous ¶7 years ago
Since the .user.ini is read from public directories, it's contents will be served to anyone requesting it and potientially show them sensitive configuration settings.
Add these lines to your .htaccess to block requests to it :
<Files ".user.ini">
Require all denied
</Files>
Anteaus at thenox dot com ¶12 years ago
"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. Thus, you unfortunately cannot create a config which caters for both types of hosting, at least not in any straightforward way.
mark at manngo dot net ¶4 years ago
Trap for young players, not that I’m such a young player myself.
The default setting for user_ini.cache_ttl is 300 seconds, which means that it refreshes every 5 minutes. If you are tweaking the settings in .user.ini, it could take up to 5 minutes before you see the results of your experimentation.
If you don’t have access to php.ini where you can change this setting, you will have to learn to be very patient.
signups at altillc dot com ¶6 years ago
For those looking for an example... .user.ini should be formatted as a simple list of [KEY]=[VALUE]\n sets. For example, a one-line .user.ini file that serves solely to change the max allowable upload file size to 5Mb is:
upload_max_filesize="5M"
interfaSys ¶15 years ago
This article should be made clearer.
".htaccess-style INI files" meant to me that the ini settings had to follow the syntax used in .htaccess, but this is not the case!
You have to use
register_globals=on
and not
php_flag register_globals on
Also, the changes can take a while to propagate to all processes if you have a long process time out.
Restarting php-fpm can give you an answer quicker :)