What is the mystery of .user.ini in php?

藏色散人
Release: 2023-04-09 21:04:01
forward
3776 people have browsed it

Recommended study: "PHP Video Tutorial"

Mysterious .user. Is the ini file

.user.ini a mysterious thing?

Let’s see what the official says:

https://www.php.net/manual/zh/configuration.file.per-user.php

Since PHP 5.3.0 Starting from , PHP supports .htaccess style INI files on a per-directory basis. Such files are only processed by the CGI/FastCGI SAPI. This feature makes PECL's htscanner extension obsolete. If using Apache, using an .htaccess file has the same effect.

Xiaobai said he didn’t understand~

As we all know, php.ini is the core configuration file of PHP and is read when PHP starts, so are other ini files in the web directory. It can be recognized by PHP. The official also said that in addition to the main php.ini, PHP will also scan INI files in each directory, starting from the directory where the executed PHP file is located and going up to the web root directory. (specified by $_SERVER['DOCUMENT_ROOT']). If the PHP file being executed is outside the web root directory, only that directory will be scanned.

In this case, all configurations can be modified by .user.ini reconfiguration?
Oh, Maga’s

You are thinking too much, the official also said:

Only those with

PHP_INI_PERDIR# in the .user.ini style INI file INI settings for ## and
PHP_INI_USER modes are recognized. Xiaobai, raise your hand again, what is PHP_INI_* mode?
The official says this:

The range in which the configuration can be specified (https://www.php.net/manual/zh/configuration.changes.modes.php)

These modes determine when, where and whether a PHP command can be set. Each instruction in the manual has a mode to which it belongs. For example, some commands can be set in PHP scripts using ini_set(), while others can only be set in php.ini or httpd.conf.

For example, the output_buffering directive belongs to

PHP_INI_PERDIR

, so it cannot be set with ini_set(). But the display_errors directive belongs to

PHP_INI_ALL and can be set anywhere, including ini_set(). Definition of PHP_INI_* mode

模式    含义
PHP_INI_USER    可在用户脚本(例如 ini_set())或 Windows 注册表(自 PHP 5.3 起)以及 .user.ini 中设定
PHP_INI_PERDIR    可在 php.ini,.htaccess 或 httpd.conf 中设定
PHP_INI_SYSTEM    可在 php.ini 或 httpd.conf 中设定
PHP_INI_ALL    可在任何地方设定
Copy after login
That is to say, only PHP_INI_USER mode can be set in

.user.ini

, so which configurations can be set in What about the settings in

.user.ini? php.ini configuration option list (https://www.php.net/manual/zh/ini.list.php)

It’s a bit interesting, not all configurations
.user.ini
can be modified, such as

disable_functions, upload_max_filesize. The answer to the thousand-year-old mystery is found here?

"No input file specified" appears when accessing the php page, and trying various methods to no avail. Have you begun to doubt your character, have you begun to suspect kidney failure, do you feel that you are so young? That won’t work?
  • In desperation, have you found a file called

    .user.ini

    in your website directory? In a fit of anger, you decided to delete it. Oh, yes, there is a way.
    What?
  • .user.ini
  • If you can’t delete it, do you feel that you are really in trouble?

    [root@Tech1024]# rm -rf .user.ini 
    rm: cannot remove ‘.user.ini’: Operation not permitted
    Copy after login
    Let’s take a look at the attributes of the file. Are you crying with joy, ah, you are finally able to do it again.

    Hey, Xiaobai may feel that he is not good again, why is it still "No input file specified"?

    Young man, don’t worry, take a look at the official website (http://php.net/manual/zh/conf... ).

    user_ini.cache_ttl
  • Controls the interval between re-reading user INI files. The default is 300 seconds (5 minutes).
  • ......

    5 difficult minutes have passed, have you cried with joy again: Hey, you can do it after all. What is the use of

    .user.ini?

    If you are curious, please click https://lnmp.org/faq/lnmp-vhost-add-howto.html#user.ini

    Finally
As an IT career People, no matter what industry they are engaged in, should bear in mind two points: technology and attitude. Technology determines your existence, and attitude determines how long you can exist.

The above is the detailed content of What is the mystery of .user.ini in php?. For more information, please follow other related articles on the PHP Chinese website!

Related labels:
php
source:segmentfault.com
Statement of this Website
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn
Popular Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template
About us Disclaimer Sitemap
php.cn:Public welfare online PHP training,Help PHP learners grow quickly!