LNMP 1.6 常见的502问题解决
在nginx上跑discuz,先修改配置文件
cd /usr/local/nginx/conf/vhosts/
vim test.conf
server { listen 80; server_name www.test.com; index index.html index.htm index.php; root /data/www; location ~ \.php$ { include fastcgi_params; fastcgi_pass unix:/tmp/www.sock; #fastcgi_pass 127.0.0.1:9000; fastcgi_index index.php; fastcgi_param SCRIPT_FILENAME /data/www$fastcgi_script_name; } }
/usr/local/nginx/sbin/nginx -t
/etc/init.d/nginx reload
在浏览器输入 www.test.com 错误502
查看nginx的错误日志,错误日志的位置在主配置文件里面
vim ../nginx.conf
搜索 /error error_log /usr/local/nginx/logs/nginx_error.log crit; 级别是crit
查看错误日志
cat /usr/local/nginx/logs/nginx_error.log
ll /tmp/www.sock
srw-rw---- 1 root root 0 12月 31 01:23 /tmp/www.sock 因为作为其他人,没有读的权限,所以502
vim /usr/local/php/etc/php-fpm.conf
[www] listen = /tmp/www.sock user = php-fpm group = php-fpm 改为 [www] listen = /tmp/www.sock user = php-fpm group = php-fpm listen.owner = nobody listen.group = nobody
/usr/local/php/sbin/php-fpm -t
/etc/init.d/php-fpm restart
刷新 没有问题