Nginx+php Show 502 Bad Gateway solution when testing

Source: Internet
Author: User
Tags fpm

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

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.