Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Why are there many php.ini files in a system?

I just want to know why both Apache httpd and php environment need a php.ini file. Does modifying one of them require updating the other?

If someone can recommend a specific book, article or tutorial to help me understand this, that would be helpful thank you.

like image 651
Chedy2149 Avatar asked Nov 13 '22 06:11

Chedy2149


1 Answers

php.ini exists for the global web server process. It can also exist for each individual vhost.

It is searched for in the following order:

  • The PHPIniDir directive defined by the vhost
  • The PHPRC environment variable (as of PHP 5.2.0)
  • If on Windows and PHP 5.2.0 or greater, the following registry keys [HKEY_LOCAL_MACHINE\SOFTWARE\PHP\x.y.z], [HKEY_LOCAL_MACHINE\SOFTWARE\PHP\x.y] and [HKEY_LOCAL_MACHINE\SOFTWARE\PHP\x], where x, y and z mean the PHP major, minor and release versions. If there is a value for IniFilePath in any of these keys, the first one found will be used as the location of the php.ini (Windows only).
  • [HKEY_LOCAL_MACHINE\SOFTWARE\PHP], value of IniFilePath (Windows only).
  • The current working directory
  • The web server's directory
  • If on Windows, the Windows directory (C:\Windows)
like image 140
Andy Avatar answered Nov 16 '22 03:11

Andy