2015-12-18 93 views
6

文件存在於路徑中,但php無法加載ini文件。 我嘗試 - 更改chmod,chown,更改配置路徑。沒有結果。PHP 7.0.1無法加載ini文件

# /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 
+0

'ls -Z'的輸出是什麼你檢查過selinux日誌嗎? – bansi

+0

SELinux被禁用 – Vovan4elli

+0

嗯,不知道然後。但我注意到的一件事是你不需要php.ini的執行權限。 – bansi

回答

5

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正在尋找錯誤的文件夾。看來,with-config-file-path沒有make clean導致的問題。

我加--with-config-file-path=/opt/php7/lib./configure並執行make clean && make && make install

它解決了這個問題。

+0

我發現相同:'/ etc/php7'不起作用,但是'/ etc/php7/cli'沒有。不知道它是否是'make clean'或額外的目錄級別。謝謝,無論如何! – halfer