Locating the php.ini File for the Command Line
When enabling extensions in the PHP environment, it's essential to use the appropriate php.ini file. For command-line (CLI) operations, a different php.ini file is used than the one for the web server.
To locate the php.ini file used by the CLI, follow these steps:
1. Run the php --ini Command:
Open the command prompt or terminal and enter the following command:
php --ini
2. Identify the Configuration File Path:
In the output of the command, look for the line that begins with "Loaded Configuration File." This line indicates the path to the php.ini file used by the CLI.
For example, you might see output like the following:
... Loaded Configuration File: /usr/local/etc/php/7.4/php.ini ...
This indicates that the php.ini file used by the CLI is located at /usr/local/etc/php/7.4/php.ini.
Example:
In the context of the given problem, you would need to locate the php.ini file used by the CLI and uncomment the line "extension=php_pdo_mysql.dll" in that file to enable the PDO MySQL extension.
The above is the detailed content of Where is the PHP CLI php.ini File Located?. For more information, please follow other related articles on the PHP Chinese website!