简体   繁体   中英

502 Bad Gateway with PHP7 and Nginx 1.9.9

I'm getting a 502 Bad Gateway error with PHP7 and nginx 1.9.9 installed on Ubuntu 14.04 when I try to access any .php files. .html files load as expected.

I've updated the default.conf to:

server {
    listen 80 default_server;

    root /usr/share/nginx/html;
    index index.html index.htm index.php;

    server_name localhost;

    location / {
        try_files $uri $uri/ /index.php$is_args$args;
    }

    location ~ \.php$ {
       fastcgi_split_path_info ^(.+\.php)(/.+)$;
       fastcgi_pass unix:/run/php/php7.0-fpm.sock;
       fastcgi_index index.php;
       include fastcgi_params;
    }
}

I've updated php.ini with cgi.fix_pathinfo = 0 and then rebooted the server, and am still getting the 502 error with all .php files. I have checked to ensure php7.0-fpm.sock is installed and in the proper location.

This is the error I'm getting from the nginx log 2016/01/19 19:14:54 [error] 1466#1466: *1 open() "/usr/share/nginx/html/xmlrpc.php" failed (2: No such file or directory), client: 85.159.237.13, server: localhost, request: "POST /xmlrpc.php HTTP/1.0", host: "my.ip.address"

I've searched for the answer for quite a while and I'm out of ideas. Does anyone have any suggestions?

This is mostly because your nginx and php7.0-fpm were not run under the same user. Edit nginx.conf and change "user nginx" to "user www-data" By the way, "client: 85.159.237.13", that was a script boy, I think.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM