No php.ini with brew

No php.ini with brew

  1. Blog
  2. 15 November 2026
  3. 3 min read

Stefan Bogdanescu

Founder & Senior Architect

The Disappearance of php.ini in macOS Homebrew PHP Installations

When you install PHP via Homebrew on macOS, the default installation path for the configuration file is /usr/local/etc/php/7.0/php.ini. However, as your source material indicates, this file often appears to be missing. Running php-fpm -i reveals a loaded configuration file path that points to nothing, resulting in an empty configuration state. This isn't a bug; it's a deliberate design choice by the Homebrew maintainers aimed at preventing common misconfigurations but frequently causes confusion for developers expecting a standard setup.

The core issue lies in how PHP determines its runtime behavior. When Loaded Configuration File returns (none), PHP falls back to a strict default configuration. While this sounds like a security feature, it breaks functionality immediately because many extensions—such as PDO, openssl, and various database drivers—are disabled by default unless explicitly enabled. Without these, your scripts will fail with fatal errors regarding missing functions or undefined constants.

To resolve this, you must manually create the configuration file or link an existing one from a different location. Homebrew does not ship with a pre-configured php.ini because it assumes users will rely on extension files located in /usr/local/etc/php/7.0/conf.d/ and system defaults. If you simply want to get your scripts running today, the most direct fix is to create an empty php.ini file at the expected location or copy one from a standard installation source like XAMPP or MAMP if you have them installed elsewhere.

# Create a basic php.ini at the Homebrew path
sudo cp /usr/local/etc/php/7.0/php.ini.default /usr/local/etc/php/7.0/php.ini 2>/dev/null || \
touch /usr/local/etc/php/7.0/php.ini

If the .default file doesn't exist, you can initialize a minimal configuration:

sudo touch /usr/local/etc/php/7.0/php.ini

Once the file exists, you must ensure that necessary extensions are enabled. This is where the real work begins. You should edit the newly created php.ini and uncomment or add lines for required modules:

; Enable common extensions
extension=pdo_mysql.so
extension=openssl.so
extension=fileinfo.so

After editing, restart your web server or PHP-FPM service to apply changes:

brew services restart php70-fpm
# Or if using Apache/Nginx with PHP built-in modules
sudo apachectl restart

A critical consideration when managing php.ini on macOS is file permissions. Since Homebrew installs into /usr/local/, the files are typically owned by root. You cannot simply drop a new config file there without elevated privileges, hence the use of sudo. However, be cautious: modifying system-wide configs can conflict with other applications that might also rely on PHP.

If you prefer a cleaner approach and want to avoid manual edits every time, consider switching to the Homebrew-provided php.ini-development template if available for your specific version, or generate a fresh one from scratch using this command:

php -r "echo ini_get('display_errors');"

This confirms whether PHP is reading your config. If it outputs On, you're good. If not, double-check the file path in your output against where you placed your file.

For production environments, remember that leaving display_errors enabled in php.ini is a significant security risk. Always set display_errors = Off and log_errors = On in production configurations. This ensures sensitive stack traces don't leak to users while errors are logged for debugging.

If you're working within the Laravel ecosystem, especially when deploying on macOS with Homebrew PHP, ensure your .env file points to the correct PHP binary. Sometimes switching between system PHP and Homebrew PHP leads to mismatched ini files. Verify consistency by running php -i | grep Configuration File.

Ultimately, the absence of a default php.ini is an intentional trade-off to force explicit configuration management, but it requires upfront effort. By creating the file and enabling necessary extensions, you regain full control over your PHP environment without relying on potentially broken defaults.

Our network