search
HomeBackend DevelopmentPHP TutorialWhat is the mystery of .user.ini in php?

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    可在任何地方设定
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
    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!

Statement
This article is reproduced at:segmentfault. If there is any infringement, please contact admin@php.cn delete
What is the difference between unset() and session_destroy()?What is the difference between unset() and session_destroy()?May 04, 2025 am 12:19 AM

Thedifferencebetweenunset()andsession_destroy()isthatunset()clearsspecificsessionvariableswhilekeepingthesessionactive,whereassession_destroy()terminatestheentiresession.1)Useunset()toremovespecificsessionvariableswithoutaffectingthesession'soveralls

What is sticky sessions (session affinity) in the context of load balancing?What is sticky sessions (session affinity) in the context of load balancing?May 04, 2025 am 12:16 AM

Stickysessionsensureuserrequestsareroutedtothesameserverforsessiondataconsistency.1)SessionIdentificationassignsuserstoserversusingcookiesorURLmodifications.2)ConsistentRoutingdirectssubsequentrequeststothesameserver.3)LoadBalancingdistributesnewuser

What are the different session save handlers available in PHP?What are the different session save handlers available in PHP?May 04, 2025 am 12:14 AM

PHPoffersvarioussessionsavehandlers:1)Files:Default,simplebutmaybottleneckonhigh-trafficsites.2)Memcached:High-performance,idealforspeed-criticalapplications.3)Redis:SimilartoMemcached,withaddedpersistence.4)Databases:Offerscontrol,usefulforintegrati

What is a session in PHP, and why are they used?What is a session in PHP, and why are they used?May 04, 2025 am 12:12 AM

Session in PHP is a mechanism for saving user data on the server side to maintain state between multiple requests. Specifically, 1) the session is started by the session_start() function, and data is stored and read through the $_SESSION super global array; 2) the session data is stored in the server's temporary files by default, but can be optimized through database or memory storage; 3) the session can be used to realize user login status tracking and shopping cart management functions; 4) Pay attention to the secure transmission and performance optimization of the session to ensure the security and efficiency of the application.

Explain the lifecycle of a PHP session.Explain the lifecycle of a PHP session.May 04, 2025 am 12:04 AM

PHPsessionsstartwithsession_start(),whichgeneratesauniqueIDandcreatesaserverfile;theypersistacrossrequestsandcanbemanuallyendedwithsession_destroy().1)Sessionsbeginwhensession_start()iscalled,creatingauniqueIDandserverfile.2)Theycontinueasdataisloade

What is the difference between absolute and idle session timeouts?What is the difference between absolute and idle session timeouts?May 03, 2025 am 12:21 AM

Absolute session timeout starts at the time of session creation, while an idle session timeout starts at the time of user's no operation. Absolute session timeout is suitable for scenarios where strict control of the session life cycle is required, such as financial applications; idle session timeout is suitable for applications that want users to keep their session active for a long time, such as social media.

What steps would you take if sessions aren't working on your server?What steps would you take if sessions aren't working on your server?May 03, 2025 am 12:19 AM

The server session failure can be solved through the following steps: 1. Check the server configuration to ensure that the session is set correctly. 2. Verify client cookies, confirm that the browser supports it and send it correctly. 3. Check session storage services, such as Redis, to ensure that they are running normally. 4. Review the application code to ensure the correct session logic. Through these steps, conversation problems can be effectively diagnosed and repaired and user experience can be improved.

What is the significance of the session_start() function?What is the significance of the session_start() function?May 03, 2025 am 12:18 AM

session_start()iscrucialinPHPformanagingusersessions.1)Itinitiatesanewsessionifnoneexists,2)resumesanexistingsession,and3)setsasessioncookieforcontinuityacrossrequests,enablingapplicationslikeuserauthenticationandpersonalizedcontent.

See all articles

Hot AI Tools

Undresser.AI Undress

Undresser.AI Undress

AI-powered app for creating realistic nude photos

AI Clothes Remover

AI Clothes Remover

Online AI tool for removing clothes from photos.

Undress AI Tool

Undress AI Tool

Undress images for free

Clothoff.io

Clothoff.io

AI clothes remover

Video Face Swap

Video Face Swap

Swap faces in any video effortlessly with our completely free AI face swap tool!

Hot Tools

SublimeText3 Linux new version

SublimeText3 Linux new version

SublimeText3 Linux latest version

MinGW - Minimalist GNU for Windows

MinGW - Minimalist GNU for Windows

This project is in the process of being migrated to osdn.net/projects/mingw, you can continue to follow us there. MinGW: A native Windows port of the GNU Compiler Collection (GCC), freely distributable import libraries and header files for building native Windows applications; includes extensions to the MSVC runtime to support C99 functionality. All MinGW software can run on 64-bit Windows platforms.

mPDF

mPDF

mPDF is a PHP library that can generate PDF files from UTF-8 encoded HTML. The original author, Ian Back, wrote mPDF to output PDF files "on the fly" from his website and handle different languages. It is slower than original scripts like HTML2FPDF and produces larger files when using Unicode fonts, but supports CSS styles etc. and has a lot of enhancements. Supports almost all languages, including RTL (Arabic and Hebrew) and CJK (Chinese, Japanese and Korean). Supports nested block-level elements (such as P, DIV),

Dreamweaver Mac version

Dreamweaver Mac version

Visual web development tools

SublimeText3 Chinese version

SublimeText3 Chinese version

Chinese version, very easy to use