I am using centos and I need to find out where is the php installation path is. Is there a command I can use to find that out. Thanks
5 Answers
I would recommend creating a new test.php files and inserting this code:
<?php
phpinfo();
?>
Then browse to test.php in a browser. This should give you a lot of information on php.
If you installed via an rpm also try
rpm -ql php
or
find / -name php.ini

- 3,040
- 1
- 19
- 23
-
insert what code? I don't see anything. – Phil Hollenback Feb 20 '11 at 05:19
-
sorry, forgot to code mark my php, fixed in post. – pablo Feb 20 '11 at 09:41
-
The real answer comes in second: phpinfo is not useful in this case. rpm -ql php, by its turn, lists what you are looking for! – aldemarcalazans Jul 28 '23 at 04:55
I'm not sure what you mean by install path, if you're talking about the binary 'which php' will probably work.
If you're referring to something else like the extension install dir and assuming your php was installed with RPMs, do a 'yum install php-devel' to get the php-config command. You can run it with no options to get a listing of everything it knows or you can request only certain info from it, here's some useful ones for your situation:
php-config --php-binary
php-config --extension-dir
php-config --include-dir
Also try running 'php -i' on the command line to get the output of phpinfo.

- 935
- 7
- 5
I believe best answer should be using linux shell command:
whereis php

- 451
- 5
- 14
-
1phpinfo is great but, in this particular case, it not only gives you tons of useless information, but also omits the majority of information you are looking for. The command above, by its turn, will show you the majority of paths you need, since you know how to use it. For example: it will not inform you where php-cgi is, unless you ask it. – aldemarcalazans Jul 28 '23 at 05:19
My install is in
/etc/php.d/
and
/usr/include/php
But I'm not sure what you are trying to accomplish

- 17,911
- 6
- 63
- 82
-
`/usr/include/php` should contain header files only (*.h) while the configuration is present in `/etc/php.d`. Usually, PHP resides in `/usr/bin` or `/usr/local/bin`. – Lekensteyn Feb 19 '11 at 20:54