1

I just executed php -i | grep "Loaded Configuration File" to find out where the configuration file of my PHP CLI is stored, but I get: Loaded Configuration File => (none). So it loads the default settings as a fallback.

How can I enable the openssl extension for PHP CLI if no configuration file is loaded?

Currently I get OpenSSL support => disabled (install ext/openssl) when calling php -i | grep -i "openssl"

Black
  • 461
  • 1
  • 8
  • 20
  • 1
    `php -i` also shows the location where it expects the configuration file to be, run `php -i |grep -i configuration`. – Gerald Schneider Sep 22 '20 at 09:15
  • Thank you. I get `Configuration File (php.ini) Path => /usr/local/lib64` but there is no php.ini file there. Can I just copy the php.ini from the "normal" php into it and restart the webserver? – Black Sep 22 '20 at 09:20
  • 1
    That's an extremely strange path to search for a configuration file, but copying it there should work. You don't need to restart the webserver if you use the CLI, the configuration file is read every time it is started from the command line. – Gerald Schneider Sep 22 '20 at 09:21

2 Answers2

2

You can get a list of all configuration files by passing the --ini flag to php:

$ php --ini

Configuration File (php.ini) Path: /opt/homebrew/etc/php/8.1
Loaded Configuration File:         /opt/homebrew/etc/php/8.1/php.ini
Scan for additional .ini files in: /opt/homebrew/etc/php/8.1/conf.d
Additional .ini files parsed:      /opt/homebrew/etc/php/8.1/conf.d/error_log.ini,
/opt/homebrew/etc/php/8.1/conf.d/ext-opcache.ini,
/opt/homebrew/etc/php/8.1/conf.d/ext-pcov.ini,
/opt/homebrew/etc/php/8.1/conf.d/ext-redis.ini,
/opt/homebrew/etc/php/8.1/conf.d/ext-xdebug.ini,
/opt/homebrew/etc/php/8.1/conf.d/php-memory-limits.ini
1

php -i also shows the location where it expects the configuration file to be, just run php -i |grep -i configuration.

Example output from my Ubuntu host:

$ php -i |grep -i configuration
Configuration File (php.ini) Path => /etc/php/7.2/cli
Loaded Configuration File => /etc/php/7.2/cli/php.ini

Just copy a php.ini file there and adapt it to your needs (or just create a symlink).

Gerald Schneider
  • 23,274
  • 8
  • 57
  • 89