Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Where can I find php.ini?

Tags:

linux

php

php-ini

A few years ago I installed Apache 2.2x and PHP 5.3.1 on a Linux server I maintain. I used .tar.gz's and built them as instructed (instead of rpms and what-have-you). And all was fine.

Today I need to install this which seems like a PHP 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. Horror of horrors. PHP works fine, except of course for this newfangled ibm_db2 thingamajig that I want to use so somebody can use a GUI to tinker with DB2. (I tried a small PHP script which fails and indicates that the ibm_db2 functions are not available.)

I have to deal with PHP once every few years, so please enlighten me at a very basic level about what I could do to enable web-based GUI access to DB2.

like image 227
necromancer Avatar asked Dec 30 '11 22:12

necromancer


People also ask

Where is PHP ini window?

In Windows Explorer, open your PHP installation folder, for example C:\PHP . Choose either the php. ini - development or php. ini - production file, and rename it php.

Where is PHP ini in file manager?

On systems that run EasyApache 3, the /usr/local/lib/ directory contains your server's php. ini file.


2 Answers

On the command line execute:

php --ini

You will get something like:

Configuration File (php.ini) Path: /etc/php5/cli
Loaded Configuration File:         /etc/php5/cli/php.ini
Scan for additional .ini files in: /etc/php5/cli/conf.d
Additional .ini files parsed:      /etc/php5/cli/conf.d/curl.ini,
/etc/php5/cli/conf.d/pdo.ini,
/etc/php5/cli/conf.d/pdo_sqlite.ini,
/etc/php5/cli/conf.d/sqlite.ini,
/etc/php5/cli/conf.d/sqlite3.ini,
/etc/php5/cli/conf.d/xdebug.ini,
/etc/php5/cli/conf.d/xsl.ini

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.

like image 187
KingCrunch Avatar answered Oct 19 '22 04:10

KingCrunch


The best way to find this is:

Create a PHP (.php) file and add the following code:

<?php phpinfo(); ?>

and open it in a browser. It will show the file which is actually being read!

Updates by the OP:

  1. The previously accepted answer is likely to be faster and more convenient for you, but it is not always correct. See comments on that answer.
  2. Please also note the more convenient alternative <?php echo php_ini_loaded_file(); ?> mentioned in this answer.
like image 31
Tejas Avatar answered Oct 19 '22 03:10

Tejas