昨天接到一个网友的问题,说yum安装nginx+php-fpm+mysql+phpMyAdmin后,发明phpMyAdmin无法打开,一直报502错误已经抓狂半天了,本着辅佐别人快乐本身的原则,长途帮他看了一下, 现记录和总结如下,问题办理思路的总结放在文章最后,问题办理思路总结也是本文的重点。
问题情况:CentOS6通过yum安装的nginx+php-fpm+mysql+phpMyAdmin
问题描写:安装完成后发明nginx没有问题,而phpMyAdmin无法打开,提示502错误
问题办理进程
查察问题情况的安装包:
nginx-filesystem-1.0.15-12.el6.noarch |
nginx-1.0.15-12.el6.x86_64 |
rrdtool-php-1.3.8-7.el6.x86_64 |
php-pear-1.9.4-4.el6.noarch |
php-devel-5.3.3-46.el6_6.x86_64 |
php-mbstring-5.3.3-46.el6_6.x86_64 |
php-mcrypt-5.3.3-3.el6.x86_64 |
php-5.3.3-46.el6_6.x86_64 |
php-tidy-5.3.3-46.el6_6.x86_64 |
php-pecl-memcache-3.0.5-4.el6.x86_64 |
php-xmlrpc-5.3.3-46.el6_6.x86_64 |
php-xmlseclibs-1.3.1-3.el6.noarch |
php-common-5.3.3-46.el6_6.x86_64 |
php-pdo-5.3.3-46.el6_6.x86_64 |
php-xml-5.3.3-46.el6_6.x86_64 |
php-fpm-5.3.3-46.el6_6.x86_64 |
php-cli-5.3.3-46.el6_6.x86_64 |
php-mysql-5.3.3-46.el6_6.x86_64 |
php-eaccelerator-0.9.6.1-1.el6.x86_64 |
php-gd-5.3.3-46.el6_6.x86_64 |
按照nginx报的502错误,可以劈头判定是upstream呈现了问题,再提到upstream之前,先列一下nginx的设置文件(去掉注释,我已经将nginx记录错误日志的级别从默认级别晋升到info)。
user nginx;
worker_processes 1;
error_log /var/log/nginx/error.log info;
pid /var/run/nginx.pid;
events {
worker_connections 1024;
}
http {
include /etc/nginx/mime.types;
default_type application/octet-stream;
client_max_body_size 10M;
log_format main '$remote_addr - $remote_user [$time_local] "$request" '
'$status $body_bytes_sent "$http_referer" '
'"$http_user_agent" "$http_x_forwarded_for"';
access_log /var/log/nginx/access.log main;
sendfile on;
keepalive_timeout 65;
include /etc/nginx/conf.d/*.conf;
}
由于此设置文件中没有显式写明任何server,因此需要查察一下include /etc/nginx/conf.d/*.conf; 所包括的默认server文件,即/etc/nginx/conf.d/default.conf,去掉注释
cat /etc/nginx/conf.d/default.conf
server {
listen 80 default_server;
server_name _;
include /etc/nginx/default.d/*.conf;
location / {
root /usr/share/nginx/html;
index index.php index.html index.htm;
}
error_page 404 /404.html;
location = /404.html {
root /usr/share/nginx/html;
}
error_page 500 502 503 504 /50x.html;
location = /50x.html {
root /usr/share/nginx/html;
}
location ~ [^/].php(/|$) {
fastcgi_split_path_info ^(.+?.php)(/.*)$;
if (!-f $document_root$fastcgi_script_name) {
return 404;
}
fastcgi_pass 127.0.0.1:9000;
fastcgi_index index.php;
include fastcgi_params;
}
}
劈头判定,此nginx的设置确实没有问题,应该是php-fpm可能php自己的问题(缩小问题范畴)。
查阅nginx日志文件(/var/log/nginx/error.log),发明如下提示,确定是php-fpm的问题,fastcgi也算是对upstream的一种署理