Ubuntu 16.04,nginx,phpmyadmin - 502 Bad Gateway

时间:2016-11-13 18:54:40

标签: php nginx phpmyadmin

我在nginx(默认文件)中使用此设置:

server {
        listen 30425;

        # Don't want to log accesses.
        #access_log  /dev/null main;
        access_log  /var/log/nginx/php.acces_log main;
        error_log   /var/log/nginx/php.error_log info;

        root /usr/share/phpmyadmin;
        index  index.php index.html index.htm;
        error_page 401 403 404 /404.php;

        location ~ .*.php$ {
                include fastcgi_params;
                fastcgi_pass  127.0.0.1:9000;
                fastcgi_index index.php;
                fastcgi_param  SCRIPT_FILENAME $document_root$fastcgi_script_name;
                fastcgi_param SERVER_NAME $http_host;
                fastcgi_ignore_client_abort on;

        }
}

当我尝试访问30425时,我收到 502 Bad Gateway 。所有其他设置都是默认设置(PHP 7)。

1 个答案:

答案 0 :(得分:0)

我必须替换此fastcgi_pass 127.0.0.1:9000;
到fastcgi_pass Unix:/var/run/php/php7.3-fpm.sock; 然后它运行完美。

完整代码。

server{
    listen 80;
    index index.html index.htm index.php;

    server_name 127.0.0.1;

    root /usr/share/phpmyadmin;
    location / {
            #try_files $uri $uri/ = 404;
            autoindex on;
    }


    location ~\.php$ {
            fastcgi_split_path_info ^(.+\.php)(/.+);
            try_files $uri $uri/ =404;
            fastcgi_pass unix:/var/run/php/php7.3-fpm.sock;
            fastcgi_index index.php;
            include fastcgi_params;
            fastcgi_param  SCRIPT_FILENAME $document_root$fastcgi_script_na$
            fastcgi_param SERVER_NAME $http_host;
            fastcgi_ignore_client_abort on;
    }

}