No php.ini with brew

32,546

Solution 1

I have the same issue. Someone has already created an issue for this:

It looks like running brew install php70 --build-from-source does create a php.ini file. It worked for me.

Solution 2

You can use the following command:

php -r "phpinfo();" | grep php.ini

it will tell you what php.ini is being executed, in my case:

▶ php -r "phpinfo();" | grep php.ini
Configuration File (php.ini) Path => /usr/local/etc/php/7.3
Loaded Configuration File => /usr/local/etc/php/7.3/php.ini

Solution 3

For php8 i did this:

cp /etc/php.ini.default /usr/local/etc/php/8.0/php.ini

/php/8.0/ php and 8.0 directories might not exist so you have to create them

check with php --ini where it is looking for conf files and if any is loaded

Solution 4

If you have installed PHP using brew and do not find php.ini file in /etc than search for php.ini.default, this is the php.ini file. Please create a copy of default php.ini and naming it php.ini using command mentioned below.

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

than restart the Apache server

sudo apachectl restart
Share:
32,546
eozzy
Author by

eozzy

UI Designer & Front-end Developer

Updated on August 12, 2021

Comments

  • eozzy
    eozzy over 2 years

    I installed PHP7 with brew and it said:

    The php.ini file can be found in:
        /usr/local/etc/php/7.0/php.ini
    

    but I don't see anything there. So I confirmed it with php-fpm -i:

    Configuration File (php.ini) Path => /usr/local/etc/php/7.0
    Loaded Configuration File => (none)
    Scan this dir for additional .ini files => /usr/local/etc/php/7.0/conf.d
    

    I think for this reason I'm unable to run PHP scripts, how do I fix it?

  • eozzy
    eozzy over 7 years
    Ah, a bit too late. After a full day of messing with brew I went back to MAMP 4, it also supports NGINX now.
  • Saitama
    Saitama almost 3 years
    Works for me too.