今天,我需要安装IBM DB2库。我完成了所有步骤,直到进行安装
,然后在 $ php_home/lib/extensions/somecomplecatedName/ibm_db2.so
中找到了ibm_db2.so。
最大的收获是最后一步是配置文件 php.ini ,但是没有任何 任何 php.ini 我的系统上的文件。 PHP当然可以正常工作,除了这个新的IBM_DB2 ThingAmajig。 (我尝试了一个小的php脚本,该脚本失败并指出IBM_DB2函数不可用。)
如何查找或设置php.ini文件,以便我可以启用所需的库?
Today I needed to install the IBM DB2 library. I went through all the steps up to make install
, and I found ibm_db2.so in $PHP_HOME/lib/extensions/somecomplicatedname/ibm_db2.so
.
The great catch is the last step is to configure file php.ini, but there aren't any php.ini files on my system. PHP works fine, except of course for this newfangled ibm_db2 thingamajig. (I tried a small PHP script which fails and indicates that the ibm_db2 functions are not available.)
How would I go about finding or setting up the php.ini file so that I can enable the library I need?
发布评论
评论(15)
在命令行执行:
您将获得类似的内容:
这是我本地的Dev-Machine。但是,第二行是有趣的。如果没有提及,请看看第一个。这就是PHP寻找
php.ini
文件的路径。您可以使用 phpinfo()在脚本中打电话,然后致电并致电它带有浏览器。在输出的第一个块中提到了它。
php -i
在命令行中执行了相同的操作,但这很不舒服。On the command line execute:
You will get something like:
That's from my local dev-machine. However, the second line is the interesting one. If there is nothing mentioned, have a look at the first one. That is the path, where PHP looks for the
php.ini
file.You can grep the same information using phpinfo() in a script and call it with a browser. It’s mentioned in the first block of the output.
php -i
does the same for the command line, but it’s quite uncomfortable.找到此问题的最佳方法是:
创建一个php( .php )文件,并添加以下代码:
并将其打开在浏览器中。它将显示实际正在阅读的文件!
OP的更新:
<?php echo php_ini_loaded_file(); ?
The best way to find this is:
Create a PHP (.php) file and add the following code:
and open it in a browser. It will show the file which is actually being read!
Updates by the OP:
<?php echo php_ini_loaded_file(); ?>
mentioned in this answer.这对我有用:
您应该看到类似的内容:
PS
仅获得php.ini路径,使用:
This works for me:
You should see something like:
P.S.
To get only the php.ini path, use:
在命令窗口中,键入
它将显示类似的路径:
如果上述命令不起作用,请使用以下方式:
In a command window, type
It will show you the path something like:
If the above command does not work then use this:
使用以下命令在Linux上找到
php.ini
文件路径。输出:
或以此方式尝试:
它显示路径结果。
Use the following command to find the
php.ini
file path on Linux.Output:
Or try this other way:
It shows the path result.
此命令应帮助您找到它
This command should help you to find it
php附带两个本机函数以显示加载哪个配置文件:
根据您的设置, apache 和 cli 可能会使用不同的.INI文件, 。以下是两个解决方案:
apache:
只需在php(.php)文件中添加以下内容,然后在浏览器中打开它:
CLI:
COPY-PASTE在您的终端中:
PHP comes with two native functions to show which configuration file is loaded:
Depending on your setup, Apache and CLI might use different .ini files. Here are the two solutions:
Apache:
Just add the following in a PHP (.php) file and open it in your browser:
CLI:
Copy-paste in your terminal:
会告诉您其位置或从命令行告诉您的位置
will tell you its location, or from the command line
尝试以下解决方案之一
在您的终端中,类型
find/-name“ php.ini”
在您的终端中,类型
php -i | Grep php.ini
。它应该显示文件路径为“配置文件(php.ini)路径=&gt;/etc”phpinfo() &lt;?php
在新线路上。这将告诉您 php.ini 位置。您也可以在交互式模式下与PHP交谈。只需在终端和类型
phpinfo();
中键入php -a
。Try one of these solutions
In your terminal, type
find / -name "php.ini"
In your terminal, type
php -i | grep php.ini
. It should show the file path as "Configuration File (php.ini) Path => /etc"If you can access one of your PHP files, open it in a editor (Notepad) and insert
phpinfo();
after<?php
on a new line. This will tell you the php.ini location.You can also talk to PHP in interactive mode. Just type
php -a
in the terminal and typephpinfo();
after the PHP interpreter initiated.在命令行中运行此:
Run this in the command line:
嘿...对我有用!
Hey... it worked for me!
您可以使用以下内容获取有关配置文件的更多信息:
You can get more information about your configuration files using something like:
对于 sapi :php-fppm:php-fppm
无需创建一个php。 info 文件(无论如何,将其留给世界都不是一个好政策)。在命令行:
输出中的某个地方,它将显示以下行:
这是一个更完整的说明:
”如何在没有info.php 的情况下找出PHP配置参数
For SAPI: php-fpm
There isn't any need to create a php.info file (it is not a good policy to leave it for the world to read anyway). On the command line:
Somewhere in its output, it will show this line:
Here is a more complete explanation:
How to Figure out Your PHP Configuration Parameters without info.php
根据此答案,如 php 7 常规php.ini文件是删除,并使用
php.ini-raproduction
和php.ini-devlopment
。因此,在我的情况下不存在不存在的php.ini(我已经安装了php 8.1),使用
php.ini-production
,它位于php安装文件夹中(类似于:c c。 :\ php-8.1.5
)并创建一个文件并将其命名php.ini
,然后在此新<php.ini-production
复制内容代码> php.ini 。according to this answer, as of PHP 7 the regular php.ini file was removed and added with
php.ini-production
andphp.ini-devlopment
.so instead of php.ini which does not exist in my case (I've installed php 8.1), use
php.ini-production
and it's located in php installation folder (something like:C:\PHP-8.1.5
) and create a file and name itphp.ini
and then copy contents ofphp.ini-production
in this newphp.ini
.检查INI配置文件
apache
/etc/php/xy/apache2/php.ini
的路径nginx
/etc/php/xy/fpm/php.ini
xy = php版本使用(可以在不同的路径中以获取更多路径)
PATHS to check for ini config file
apache
/etc/php/X.Y/apache2/php.ini
nginx
/etc/php/X.Y/fpm/php.ini
XY=PHP Version used (could be in different paths for more paths)