3

I have installed PHP v7.2. when I do php -v in my terminal, I get:

$ php -v
PHP 7.2.0-2+ubuntu16.04.1+deb.sury.org+2 (cli) (built: Dec  7 2017 20:14:31) ( NTS )
Copyright (c) 1997-2017 The PHP Group
Zend Engine v3.2.0, Copyright (c) 1998-2017 Zend Technologies
    with Zend OPcache v7.2.0-2+ubuntu16.04.1+deb.sury.org+2, Copyright (c) 1999-2017, by Zend Technologies

Which php, gives me, /usr/bin/php?

But there is no php.ini in that directory. How can I find the location of php.ini?

3
  • locate php.ini will search for it. Though you also will need to update it with updatedb once after installing (the database is not realtime to speed searching up by a lot).
    – Rinzwind
    Jan 3, 2018 at 10:20
  • $ updatedb updatedb: can not open a temporary file for `/var/lib/mlocate/mlocate.db' Jan 3, 2018 at 10:31
  • You need sudo.
    – Rinzwind
    Jan 3, 2018 at 12:22

2 Answers 2

8

You cand find the php.ini file in the following directories:

  • /etc/php/7.0/apache2/php.ini
  • /etc/php/7.0/cli/php.ini

Hope it helps.

4
  • Where 7.0 is the version of PHP. You could include these commands with a little explanation, also the Rinzwind's comment, in your answer to make it complete. :-)
    – pa4080
    Jan 3, 2018 at 10:30
  • This is for the apache installation. This is differnet from what you get by running php in the terminal Jan 3, 2018 at 10:32
  • In that case, execute in your terminal sudo updatedb and then execute locate php.ini this will show the location of all php.ini files in your system.
    – galoget
    Jan 3, 2018 at 10:34
  • @RamasamyViswanathan - look at the second bullet - cli means command-line-interface.
    – pa4080
    Jan 3, 2018 at 10:39
1

You can also make a file that calls the phpinfo() function. Simply add the following code into a file such as phpinfo.php in your webroot, and access it via the webserver.

<?php
phpinfo();
?>

Where is my PHP php.ini Configuration File Located

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.