php.ini File Location at MacOS Catalina

Disable PHP Warning Message

I wanted to disable my warning message from my php installation. To do so

I need to configure my php.ini file. I searched on the internet but couldn’t find a direct answers where to change my php.ini on MacOS Catalina.

php warning appears
php warning appears

Location of php.ini File at MacOS Catalina

For MacOS Catalina the location of php.ini is located at /etc/

You can verify it by printing phpinfo() and look for “Loaded Configuration File (php.ini) path”

phpinfo location of php.ini
phpinfo location of php.ini

For my MacOS Catalina, the location of php.ini is located at /etc/. As you can see there is no php.ini is loaded (None).

Load Your Own php.ini File

To load your own php.ini, copy the default file into your new php.ini

sudo cp /etc/php.ini.default /etc/php.ini

Open the php.ini, in this case I’m using atom to open it.

sudo atom /etc/php.ini

Then change php error reporting into

error_reporting = E_ERROR

Save it then restart apache.

sudo apachectl restart

Then check the php.ini file is loaded correctly by printing the phpinfo. It will shows /etc/php.ini at “Loaded Configuration File” row.

phpinfo loaded php ini at macos catalina
phpinfo loaded php ini at macos catalina

or you can run php –ini to see the loaded configuration file.

macos php ini command
macos php ini command

When you refresh the website, the warning php message will disappear.

php warning message disappear
php warning message disappear