Home >Backend Development >PHP Tutorial >How to Find the Active \'php.ini\' File on a Linux Ubuntu Server?
Determining the Active 'php.ini' File Path
When managing multiple 'php.ini' files on a Linux Ubuntu server, it becomes crucial to identify the one being used. The 'find / -name php.ini' command may reveal numerous instances, but how do you determine the specific file employed by a PHP script web page?
PHP provides two convenient methods to ascertain the active 'php.ini' file:
Command-Line:
Execute the following command in the terminal:
<code class="php">php --ini</code>
This returns the path to the configuration file being used, as well as any additional .ini files parsed from the 'php.d' directory.
Webserver-SAPIs (e.g., Apache or Nginx):
In the PHP script, use the 'phpinfo()' function to retrieve information about the PHP configuration. Under the "Configuration File (php.ini) Path" heading, you will find the location of the active 'php.ini' file.
Here's an example output from 'php --ini':
<code class="bash">bash-3.2# php --ini Configuration File (php.ini) Path: /usr/local/php5/lib Loaded Configuration File: /usr/local/php5/lib/php.ini Scan for additional .ini files in: /usr/local/php5/php.d Additional .ini files parsed: /usr/local/php5/php.d/10-extension_dir.ini, /usr/local/php5/php.d/20-extension-opcache.ini, /usr/local/php5/php.d/40-openssl.ini, /usr/local/php5/php.d/50-extension-apcu.ini, /usr/local/php5/php.d/50-extension-curl.ini, /usr/local/php5/php.d/50-extension-gmp.ini, /usr/local/php5/php.d/50-extension-imap.ini, /usr/local/php5/php.d/50-extension-intl.ini, /usr/local/php5/php.d/50-extension-mcrypt.ini, /usr/local/php5/php.d/50-extension-mssql.ini, /usr/local/php5/php.d/50-extension-pdo_pgsql.ini, /usr/local/php5/php.d/50-extension-pgsql.ini, /usr/local/php5/php.d/50-extension-propro.ini, /usr/local/php5/php.d/50-extension-raphf.ini, /usr/local/php5/php.d/50-extension-readline.ini, /usr/local/php5/php.d/50-extension-xdebug.ini, /usr/local/php5/php.d/50-extension-xsl.ini, /usr/local/php5/php.d/60-extension-pecl_http.ini, /usr/local/php5/php.d/99-liip-developer.ini</code>
By utilizing these methods, you can quickly identify the 'php.ini' file being used by your PHP script, ensuring that any configuration changes are applied to the correct file.
The above is the detailed content of How to Find the Active 'php.ini' File on a Linux Ubuntu Server?. For more information, please follow other related articles on the PHP Chinese website!