How to find your php.ini file

Table of Contents

PHP uses an INI file for all of it's configuration. It gets loaded when PHP starts up and is used to configure extensions and various PHP features.

How you locate your php.ini file all depends on what sort of access you have to your server. I'll detail a couple of different methods below.

If you have access to php through the command-line (inside of your terminal - maybe via SSH), you can find the php.ini file quite quickly.

  1. Open your terminal locally or connected to your server via SSH.
  2. Run the php --ini command.
  3. Locate the path to the php.ini file in the output.
% php --ini
Configuration File (php.ini) Path: /opt/homebrew/etc/php/8.2
Loaded Configuration File:         /opt/homebrew/etc/php/8.2/php.ini
Scan for additional .ini files in: /opt/homebrew/etc/php/8.2/conf.d
Additional .ini files parsed:      /opt/homebrew/etc/php/8.2/conf.d/error_log.ini,

If you can load a PHP script in the browser, you can use the phpinfo() function to output all of PHP's configuration values and find the path to the php.ini file.

Put the following snippet of code into a PHP file and load the file in your browser.


Enjoyed this post or found it useful? Please consider sharing it on Twitter.