【问题标题】:PHP 7.0.1 couldn't load ini filePHP 7.0.1 无法加载 ini 文件
【发布时间】:2016-03-24 20:26:33
【问题描述】:

路径中存在文件,但 php 无法加载 ini 文件。 我尝试什么 - 更改 chmod、chown、更改配置路径。没有结果。

# /opt/php7/bin/php -i
phpinfo()
PHP Version => 7.0.1

System => Linux portal-app 3.8.13-68.1.3.el7uek.x86_64 #2 SMP Wed Apr 22 11:51:54 PDT 2015 x86_64
Build Date => Dec 18 2015 10:01:55
Configure Command =>  './configure'  '--prefix=/opt/php7' '--exec- prefix=/opt/php7' '--enable-fpm' '--with-fpm-user=user' '--with-fpm-group=nginx' '--disable-cgi' '--disable-short-tags' '--with-openssl' '--with-zlib' '--with-curl' '--with-snmp' '--with-xmlrpc' '--with-gd' '--with-jpeg-dir' '--with-png-dir' '--with-zlib-dir' '--enable-gd-native-ttf' '--with-freetype-dir' '--with-gettext' '--enable-exif' '--enable-intl' '--enable-ftp' '--enable-zip' '--with-mcrypt' '--with-imap=/opt/distrib/php7/ext/imap-2007f' '--with-imap-ssl' '--with-ldap' '--with-ldap-sasl' '--enable-mbstring' '--enable-soap' '--enable-pcntl' '--enable-sockets' '--enable-bcmath' '--enable-mysqlnd' '--with-pdo-mysql' '--with-pdo-pgsql' '--with-pgsql' '--with-libdir=lib64' '--with-fpm-systemd'
Server API => Command Line Interface
Virtual Directory Support => disabled
Configuration File (php.ini) Path => /opt/php7/lib
Loaded Configuration File => (none)
Scan this dir for additional .ini files => (none)
Additional .ini files parsed => (none)
PHP API => 20151012
PHP Extension => 20151012
Zend Extension => 320151012

# ls -la /opt/php7/lib
drwxr-xr-x 15 root root  4096 дек  8 09:24 php
-rwxr-xr-x  1 php  nginx  760 дек 18 10:12 php.ini

【问题讨论】:

  • ls -Z 的输出是什么,你检查过 selinux 日志吗?
  • 嗯嗯不知道。但我注意到的一件事是您不需要 php.ini 的执行权限。
  • 把权限改成0755,没有结果:(
  • 你看到这个帖子了吗? stackoverflow.com/questions/10711698/… .. 他们建议做一个 make clean 但不知道为什么这很重要
  • 如果您使用--with-config-file-path=/opt/php7/lib --sysconfdir=/opt/php7/lib 编译,它可以工作吗?在我的 php 中,它明确引用了这 2 个配置参数和路径。

标签: php php-7


【解决方案1】:

strace 帮我找到了问题。

# echo "<?php phpinfo() ?>" | strace /opt/php7/bin/php  2>&1 | grep php.ini
open("/etc/php7/php.ini/php-cli.ini", O_RDONLY) = -1 ENOTDIR (Not a directory)
open("/opt/php7/bin/php.ini", O_RDONLY) = -1 ENOENT (No such file or directory)
open("/etc/php7/php.ini/php.ini", O_RDONLY) = -1 ENOTDIR (Not a directory)

我不明白为什么,但是 PHP 在错误的文件夹中查找。似乎没有make clean的更改with-config-file-path会导致问题。

我将--with-config-file-path=/opt/php7/lib 添加到./configure 并执行make clean &amp;&amp; make &amp;&amp; make install

它解决了问题。

【讨论】:

  • 我发现了同样的情况:/etc/php7 不起作用,但 /etc/php7/cli 起作用。不确定是make clean 还是额外级别的目录。谢谢,无论如何!
猜你喜欢
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 2011-12-08
  • 2013-08-20
  • 2014-02-07
  • 2016-10-19
  • 1970-01-01
相关资源
最近更新 更多