早上修改了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,如需转载请自行联系原作者