Home >Backend Development >PHP Tutorial >How Do I Determine the Active \'php.ini\' File\'s Location?

How Do I Determine the Active \'php.ini\' File\'s Location?

Linda Hamilton
Linda HamiltonOriginal
2024-10-24 17:57:02491browse

How Do I Determine the Active 'php.ini' File's Location?

How to Identify the Active 'php.ini' File

When searching for the location of the 'php.ini' file on a Linux Ubuntu server, multiple files may be found using the 'find / -name php.ini' command. To determine the precise location of the active 'php.ini' file from a PHP script web page, you can utilize the following methods:

Using the 'php --ini' Command

Execute the following command from the command line:

php --ini

This command will display the path to the 'php.ini' file that is being used by the PHP interpreter.

Using 'phpinfo()' for Web Server-SAPIs

For web servers using SAPIs (Server Application Programming Interfaces), you can use the 'phpinfo()' function in a PHP script to retrieve information about the currently used 'php.ini' file. Add the following code to a PHP script:

<code class="php"><?php phpinfo(); ?></code>

Load the script in a web browser, and within the output, search for the "Loaded Configuration File" section. This will indicate the location of the active 'php.ini' file.

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>

The above is the detailed content of How Do I Determine the Active \'php.ini\' File\'s Location?. For more information, please follow other related articles on the PHP Chinese website!

Statement:
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