Π€Π°ΠΉΠ»Ρ‹ .user.ini

Π’ΠΊΠ»ΡŽΡ‡Π΅Π½Π° ΠΏΠΎΠ΄Π΄Π΅Ρ€ΠΆΠΊΠ° INI-Ρ„Π°ΠΉΠ»ΠΎΠ² Π² стилС .htaccess Π½Π° ΡƒΡ€ΠΎΠ²Π½Π΅ ΠΊΠ°Ρ‚Π°Π»ΠΎΠ³Π°. Π­Ρ‚ΠΈ Ρ„Π°ΠΉΠ»Ρ‹ ΠΎΠ±Ρ€Π°Π±Π°Ρ‚Ρ‹Π²Π°ΡŽΡ‚ΡΡ Ρ‚ΠΎΠ»ΡŒΠΊΠΎ CGI/FastCGI SAPI. Π­Ρ‚Π° функция Π΄Π΅Π»Π°Π΅Ρ‚ Π½Π΅Π½ΡƒΠΆΠ½Ρ‹ΠΌ ΠΌΠΎΠ΄ΡƒΠ»ΡŒ PECL htscanner. Если PHP Ρ€Π°Π±ΠΎΡ‚Π°Π΅Ρ‚ ΠΊΠ°ΠΊ ΠΌΠΎΠ΄ΡƒΠ»ΡŒ Apache, Ρ‚ΠΎ для достиТСния Ρ‚ΠΎΠ³ΠΎ ΠΆΠ΅ эффСкта, Ρ€Π°Π±ΠΎΡ‚Π°ΡŽΡ‚ с Ρ„Π°ΠΉΠ»Π°ΠΌΠΈ .htaccess.

Π’ Π΄ΠΎΠΏΠΎΠ»Π½Π΅Π½ΠΈΠ΅ ΠΊ основному Ρ„Π°ΠΉΠ»Ρƒ php.ini PHP ΠΈΡ‰Π΅Ρ‚ INI-Ρ„Π°ΠΉΠ»Ρ‹ Π² ΠΊΠ°ΠΆΠ΄ΠΎΠΉ Π΄ΠΈΡ€Π΅ΠΊΡ‚ΠΎΡ€ΠΈΠΈ, начиная с Π΄ΠΈΡ€Π΅ΠΊΡ‚ΠΎΡ€ΠΈΠΈ Π·Π°ΠΏΡ€ΠΎΡˆΠ΅Π½Π½ΠΎΠ³ΠΎ PHP-Ρ„Π°ΠΉΠ»Π° ΠΈ ΠΏΡ€ΠΎΠ΄ΠΎΠ»ΠΆΠ°Π΅Ρ‚ поиск Π΄ΠΎ ΠΊΠΎΡ€Π½Π΅Π²ΠΎΠΉ Π΄ΠΈΡ€Π΅ΠΊΡ‚ΠΎΡ€ΠΈΠΈ (установлСнной Π² элСмСнтС $_SERVER['DOCUMENT_ROOT']). Если PHP-Ρ„Π°ΠΉΠ» Π»Π΅ΠΆΠΈΡ‚ Π²Π½Π΅ ΠΊΠΎΡ€Π½Π΅Π²ΠΎΠΉ Π΄ΠΈΡ€Π΅ΠΊΡ‚ΠΎΡ€ΠΈΠΈ, Ρ‚ΠΎ сканируСтся Ρ‚ΠΎΠ»ΡŒΠΊΠΎ Π΅Π³ΠΎ дирСктория.

Волько INI-настройки с Ρ€Π΅ΠΆΠΈΠΌΠ°ΠΌΠΈ INI_PERDIR ΠΈ INI_USER Ρ€Π°ΡΠΏΠΎΠ·Π½Π°ΡŽΡ‚ΡΡ Π² INI-Ρ„Π°ΠΉΠ»Π°Ρ… Π² стилС .user.ini.

Π”Π²Π΅ Π½ΠΎΠ²Ρ‹Ρ… INI-Π΄ΠΈΡ€Π΅ΠΊΡ‚ΠΈΠ²Ρ‹ β€” user_ini.filename ΠΈ user_ini.cache_ttl β€” ΠΊΠΎΠ½Ρ‚Ρ€ΠΎΠ»ΠΈΡ€ΡƒΡŽΡ‚ Ρ€Π°Π±ΠΎΡ‚Ρƒ с ΠΏΠΎΠ»ΡŒΠ·ΠΎΠ²Π°Ρ‚Π΅Π»ΡŒΡΠΊΠΈΠΌΠΈ INI-Ρ„Π°ΠΉΠ»Π°ΠΌΠΈ.

Π”ΠΈΡ€Π΅ΠΊΡ‚ΠΈΠ²Π° user_ini.filename устанавливаСт имя Ρ„Π°ΠΉΠ»Π°, ΠΏΠΎ ΠΊΠΎΡ‚ΠΎΡ€ΠΎΠΌΡƒ PHP ΠΏΡ€ΠΎΠΈΠ·Π²ΠΎΠ΄ΠΈΡ‚ поиск Π² ΠΊΠ°ΠΆΠ΄ΠΎΠΉ Π΄ΠΈΡ€Π΅ΠΊΡ‚ΠΎΡ€ΠΈΠΈ; Ссли установили ΠΏΡƒΡΡ‚ΡƒΡŽ строку, PHP Π½Π΅ ΠΏΡ€ΠΎΠΈΠ·Π²ΠΎΠ΄ΠΈΡ‚ поиск. Π—Π½Π°Ρ‡Π΅Π½ΠΈΠ΅ ΠΏΠΎ ΡƒΠΌΠΎΠ»Ρ‡Π°Π½ΠΈΡŽ β€” .user.ini.

Π”ΠΈΡ€Π΅ΠΊΡ‚ΠΈΠ²Π° user_ini.cache_ttl устанавливаСт, насколько часто ΠΏΠΎΠ»ΡŒΠ·ΠΎΠ²Π°Ρ‚Π΅Π»ΡŒΡΠΊΠΈΠ΅ INI-Ρ„Π°ΠΉΠ»Ρ‹ Π±ΡƒΠ΄ΡƒΡ‚ ΠΎΠ±Π½ΠΎΠ²Π»ΡΡ‚ΡŒΡΡ. По ΡƒΠΌΠΎΠ»Ρ‡Π°Π½ΠΈΡŽ ΠΏΠ΅Ρ€ΠΈΠΎΠ΄ обновлСния составляСт 300 сСкунд (5 ΠΌΠΈΠ½ΡƒΡ‚).

οΌ‹Π”ΠΎΠ±Π°Π²ΠΈΡ‚ΡŒ

ΠŸΡ€ΠΈΠΌΠ΅Ρ‡Π°Π½ΠΈΡ ΠΏΠΎΠ»ΡŒΠ·ΠΎΠ²Π°Ρ‚Π΅Π»Π΅ΠΉ 6 notes

up
35
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.
up
30
Anteaus at thenox dot com ΒΆ
11 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.
up
22
Anonymous ΒΆ
6 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>
up
14
mark at manngo dot net ΒΆ
3 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.
up
10
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"
up
5
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 :)