参考内容:http://www.cnblogs.com/argb/p/3604340.html
早上修改了php的配置文件,php-fpm.conf,重启nginx,php-fpm后发现网站启动不来了。nginx错误日志为:
2015/09/18 10:11:30 [error] 15081#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 PHP message: PHP Fatal error: require_once(): Failed opening required ‘Zend/Application.php‘ (include_path=‘/web/www.XXX.com/wwwroot/library:.:/usr/local/lib/php‘) in /web/www.XXX.com/wwwroot/public/index.php on line 18" while reading response header from upstream, client: xxx.19.116.133, server: www.XXX.com, request: "GET / HTTP/1.1", upstream: "fastcgi://unix:/usr/local/php/var/run/www.XXX.com.socket:", host: "www.XXX.com"
通过好长时间的分析,是php.ini里面的zend配置没有生效,因此有可能是php.ini文件没有被加载。
首先检查PHP的编译参数
[[email protected] ~]$ /usr/local/php/bin/php -i|grep configure Configure Command => ‘./configure‘ ‘--prefix=/usr/local/php‘ ‘--with-config-file-path=/usr/local/php/etc‘ ‘--with-mysql=/usr/local/mysql‘ ‘--with-mysqli=/usr/local/mysql/bin/mysql_config‘ ‘--with-mysql-sock=/tmp/mysql.sock‘ ‘--with-pdo-mysql=/usr/local/mysql‘ ‘--with-gd‘ ‘--enable-libxml‘ ‘--enable-xml‘ ‘--enable-bcmath‘ ‘--enable-shmop‘ ‘--enable-sysvsem‘ ‘--enable-inline-optimization‘ ‘--with-curlwrappers‘ ‘--enable-mbregex‘ ‘--enable-fpm‘ ‘--enable-mbstring‘ ‘--enable-ftp‘ ‘--enable-gd-native-ttf‘ ‘--with-openssl‘ ‘--enable-pcntl‘ ‘--enable-sockets‘ ‘--with-xmlrpc‘ ‘--enable-zip‘ ‘--enable-soap‘ ‘--without-pear‘ ‘--with-gettext‘ ‘--enable-session‘ ‘--with-mcrypt‘ ‘--with-curl‘ ‘--enable-ctype‘ ‘--with-freetype-dir‘
--with-freetype-dir参数是后面重新编译添加的参数,也就是说,PHP经历过两次编译.
查看php的php.ini文件默认路径:
[[email protected] ~]$ /usr/local/php/bin/php -i|grep php.ini Configuration File (php.ini) Path => /usr/local/php/etc Loaded Configuration File => /usr/local/lib/php.ini
由此可以看出,此时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文件
[[email protected] etc]# /usr/local/php/sbin/php-fpm -c /usr/local/php/etc/php.ini
解决问题
思考:php文件:php-fpm.conf php.ini两个文件,php-fpm.conf是 php-fpm进程服务的配置文件
php.ini是php运行核心配置文件,也是php扩展的配置文件,比如
extension=memcache.so extension=yaf.so extension=redis.so
在php.ini里面将扩展内容配置才能生效.
因此本案件中,zend扩展没有生效,就可以查找php.ini文件是否生效.
时间: 2024-10-11 21:42:58