错误示下:
php -i | grep Load
Loaded Configuration File => (none)
libXML Loaded Version => 20901
解决办法:
使用strace去追踪一下:
#strace /usr/local/php/bin/php -i 2> /tmp/1.log
grep 'php.ini' /tmp/1.log 显示如下信息:
open("/usr/local/php-7.0.23/bin/php-cli.ini", O_RDONLY) = -1 ENOENT (No such file or directory)
open("/usr/local/php/etc/php-cli.ini", O_RDONLY) = -1 ENOENT (No such file or directory)
open("/usr/local/php-7.0.23/bin/php.ini", O_RDONLY) = -1 ENOENT (No such file or directory)
open("/usr/local/php/etc/php.ini", O_RDONLY) = -1 ENOENT (No such file or directory)
openat(AT_FDCWD, "/usr/local/php/etc/php.d", O_RDONLY|O_NONBLOCK|O_DIRECTORY|O_CLOEXEC) = -1 ENOENT (No such file or directory)
把php.ini复制到/usr/local/php-7.0.23/bin/下,然后配置文件加载成功了。 #cp /usr/local/php-7.0.23/etc/php.ini /usr/local/php-7.0.23/bin/
注:如果编译时指定配置文件路径(--with-config-file-path=/usr/local/php-7.0.23/etc),PHP会先去加载指定的配置文件,如果未找到会去找默认配置文件存放路径。