Http://www.apelearn.com/study_v2/chapter18.html
Since Amin's PHP version is 5.3, I've loaded 5.5.
502 errors occurred in the test
View logs with nginx error log for troubleshooting Vim/usr/local/nginx/logs/nginx_error.log
Display: Connect () to Unix:/tmp/php-fcgi.sock failed (13:permission denied) and connecting to upstream, client:127.0.0.1, Server:localhost, Request: "Get/2.php http/1.1", Upstream: "Fastcgi://unix:/tmp/php-fcgi.sock:", Host: "LocalHost"
Workaround One:
# ll/tmp
SRW-RW----1 root root 0 Feb 00:58 php-fcgi.sock
Modified Permissions
[Email protected] nginx]# chmod 777/tmp/php-fcgi.sock
[Email protected] nginx]# ll/tmp
srwxrwxrwx 1 root root 0 Feb 00:58 php-fcgi.sock
Test succeeded after modifying permissions
Restart Service PHP-FPM Restart
Service Nginx Restart
# ll/tmp
SRW-RW----1 root root 0 Feb 00:58 php-fcgi.sock
The permissions are back to the same
After modifying vim/etc/init.d/php-fpm in start) fi plus chmod 777/tmp/php-fcgi.sock
Workaround Two:
Configuration error because Nginx can not find php-fpm, so error, is generally fastcgi_pass after the path configuration is wrong, the back may be socket or ip:port
Modify PHP-FPM configuration file vim/usr/local/php/etc/php-fpm.conf inside listen =/tmp/php-fcgi.sock to listen = 127.0.0.1:9000
Modify Nginx configuration file vim/usr/local/nginx/conf/nginx.conf inside the Fastcgi_pass unix:/tmp/php-fcgi.sock; instead of Fastcgi_pass 127.0.0.1:9000;
Nginx+php Show 502 Bad Gateway solution when testing