早上修改了php的配置檔案,php-fpm.conf,重新開機nginx,php-fpm後發現網站啟動不來了。nginx錯誤日志為:
<code>2015</code><code>/09/18</code> <code>10:11:30 [error] 15081</code><code>#0: *1073 FastCGI sent in stderr: "PHP message: PHP Warning: require_once(Zend/Application.php): failed to open stream: No such file or directory in /web/www.XXX.com/wwwroot/public/index.php on line 18</code>
<code>PHP message: PHP Fatal error: require_once(): Failed opening required </code><code>'Zend/Application.php'</code> <code>(include_path=</code><code>'/web/www.XXX.com/wwwroot/library:.:/usr/local/lib/php'</code><code>) </code><code>in</code> <code>/web/www</code><code>.XXX.com</code><code>/wwwroot/public/index</code><code>.php on line 18</code><code>" while reading response header from upstream, client: xxx.19.116.133, server: www.XXX.com, request: "</code><code>GET / HTTP</code><code>/1</code><code>.1</code><code>", upstream: "</code><code>fastcgi:</code><code>//unix</code><code>:</code><code>/usr/local/php/var/run/www</code><code>.XXX.com.socket:</code><code>", host: "</code><code>www.XXX.com"</code>
通過好長時間的分析,是php.ini裡面的zend配置沒有生效,是以有可能是php.ini檔案沒有被加載。
首先檢查PHP的編譯參數
<code>[huwei@xxx ~]$ </code><code>/usr/local/php/bin/php</code> <code>-i|</code><code>grep</code> <code>configure</code>
<code>Configure Command => </code><code>'./configure'</code> <code>'--prefix=/usr/local/php'</code> <code>'--with-config-file-path=/usr/local/php/etc'</code> <code>'--with-mysql=/usr/local/mysql'</code> <code>'--with-mysqli=/usr/local/mysql/bin/mysql_config'</code> <code>'--with-mysql-sock=/tmp/mysql.sock'</code> <code>'--with-pdo-mysql=/usr/local/mysql'</code> <code>'--with-gd'</code> <code>'--enable-libxml'</code> <code>'--enable-xml'</code> <code>'--enable-bcmath'</code> <code>'--enable-shmop'</code> <code>'--enable-sysvsem'</code> <code>'--enable-inline-optimization'</code> <code>'--with-curlwrappers'</code> <code>'--enable-mbregex'</code> <code>'--enable-fpm'</code> <code>'--enable-mbstring'</code> <code>'--enable-ftp'</code> <code>'--enable-gd-native-ttf'</code> <code>'--with-openssl'</code> <code>'--enable-pcntl'</code> <code>'--enable-sockets'</code> <code>'--with-xmlrpc'</code> <code>'--enable-zip'</code> <code>'--enable-soap'</code> <code>'--without-pear'</code> <code>'--with-gettext'</code> <code>'--enable-session'</code> <code>'--with-mcrypt'</code> <code>'--with-curl'</code> <code>'--enable-ctype'</code> <code>'--with-freetype-dir'</code>
--with-freetype-dir參數是後面重新編譯添加的參數,也就是說,PHP經曆過兩次編譯.
檢視php的php.ini檔案預設路徑:
<code>[huwei@xxx ~]$ </code><code>/usr/local/php/bin/php</code> <code>-i|</code><code>grep</code> <code>php.ini</code>
<code>Configuration File (php.ini) Path => </code><code>/usr/local/php/etc</code>
<code>Loaded Configuration File => </code><code>/usr/local/lib/php</code><code>.ini</code>
由此可以看出,此時php預設加載的php.ini檔案存在路徑是:/usr/local/lib/php.ini
而我的正确的php.ini檔案存在路徑為:/usr/local/php/etc/php.ini
經檢查,/usr/local/lib/php.ini的确沒有配置zend擴充,是以網站無法啟動.
cp /usr/local/php/etc/php.ini /usr/local/lib/php.ini
将php.ini檔案覆寫過去,重新開機php-fpm,網站OK
或者使用指令直接加載php.ini檔案
<code>[root@test31 etc]</code><code># /usr/local/php/sbin/php-fpm -c /usr/local/php/etc/php.ini</code>
解決問題
思考:php檔案:php-fpm.conf php.ini兩個檔案,php-fpm.conf是 php-fpm程序服務的配置檔案
php.ini是php運作核心配置檔案,也是php擴充的配置檔案,比如
<code>extension=memcache.so</code>
<code>extension=yaf.so</code>
<code>extension=redis.so</code>
在php.ini裡面将擴充内容配置才能生效.
是以本案件中,zend擴充沒有生效,就可以查找php.ini檔案是否生效.
本文轉自 yawei555 51CTO部落格,原文連結:http://blog.51cto.com/huwei555/1696041,如需轉載請自行聯系原作者