164

I can't find PHP.ini location on my server. I've checked all Stack Overflow answers but I can't find my php.ini location.

I have Linux, Cent OS, zPanel. Last version of PHP.

My computer: Linux Mint 15 KDE.

0

5 Answers 5

344

In your terminal/console (only Linux, in windows you need Putty)

ssh user@ip php -i | grep "Loaded Configuration File" 

And it will show you something like this Loaded Configuration File => /etc/php.ini.

ALTERNATIVE METHOD

You can make a php file on your website, which run: <?php phpinfo(); ?>, and you can see the php.ini location on the line with: "Loaded Configuration File".

Update This command gives the path right away

cli_php_ini=php -i | grep /.+/php.ini -oE #ref. https://stackoverflow.com/a/15763333/248616 php_ini="${cli_php_ini/cli/apache2}" #replace cli by apache2 ref. https://stackoverflow.com/a/13210909/248616 
Sign up to request clarification or add additional context in comments.

8 Comments

This is not the php.ini for all things. Its for the CLI. on ubuntu 16.04 / php7.0 (default); this is going to give you /etc/php/7.0/cli/php.ini (or similar) for apache it will be at /etc/php/7.0/apache2/php.ini Php info will only give you the highest level of php.ini; so if you drop info in an html dir, it will show THAT one (not default apache, etc) Please update answer, its near complete ;)
php -i | grep "php.ini" is more easy to remember. ;)
php -i | grep php.ini is even easier
note that php -i tells the php.ini for CLI not the apache's one
php --ini is doing the same thing right?
|
36

On most installs you can find it here:

/etc/php.ini 

2 Comments

How can you change the loaded configuration file from /usr/local/lib/php.ini to /etc/php.ini ?
33

You can find the path to php.ini in the output of phpinfo(). See under "Loaded Configuration File".

enter image description here

1 Comment

No problem, just two different ways of doing it. Might be helpful to others later.
13
php -i |grep 'Configuration File' 

1 Comment

This is my preferred method because you don't have to search the file to see it.
7

#php -i | grep php.ini also will work too!

Comments

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.