服务PHP文件时出错(502坏网关) - NGINX

时间:2017-04-01 07:26:29

标签: php ubuntu nginx

配置: Ubuntu 16.04 nginx的/ 1.10.3 PHP7.0-FPM

HTML文件服务很好。打开任何.php文件时,我得到502网关错误。

 systemctl status php7.0-fpm
● php7.0-fpm.service - The PHP 7.0 FastCGI Process Manager
   Loaded: loaded (/lib/systemd/system/php7.0-fpm.service; enabled; vendor preset: enabled)
   Active: **active (running)** since Sat 2017-04-01 12:37:25 IST; 11min ago
  Process: 29729 ExecReload=/bin/kill -USR2 $MAINPID (code=exited, status=0/SUCCESS)
  Process: 29720 ExecReload=/usr/lib/php/php7.0-fpm-checkconf (code=exited, status=0/SUCCESS)
  Process: 29671 ExecStartPre=/usr/lib/php/php7.0-fpm-checkconf (code=exited, status=0/SUCCESS)
 Main PID: 29682 (php-fpm7.0)
   Status: "Processes active: 0, idle: 2, Requests: 0, slow: 0, Traffic: 0req/sec"
Tasks: 3
   Memory: 19.2M
  CPU: 202ms
   CGroup: /system.slice/php7.0-fpm.service
       ├─29682 php-fpm: master process (/etc/php/7.0/fpm/php-fpm.conf)
       ├─29734 php-fpm: pool www
       └─29735 php-fpm: pool www

nano / etc / nginx / sites-available / default

server {
    listen 80 default_server;
    listen [::]:80 default_server;

    root /var/www/html;
    index index.php index.html index.htm index.nginx-debian.html;

    server_name localhost;

    location / {
        try_files $uri $uri/ =404;
    }

    location ~ \.php$ {

#        include snippets/fastcgi-php.conf;
        fastcgi_pass unix:/run/php/php7.0-fpm.sock;
    }

    location ~ /\.ht {
        deny all;
    }
}

如果我取消注释include snippets / fastcgi-php.conf;我收到此错误

sudo nginx -t
nginx: [emerg] open() "/etc/nginx/snippets/fastcgi-php.conf" failed (2: No such file or directory) in /etc/nginx/sites-available/default:15
nginx: configuration file /etc/nginx/nginx.conf test failed

我没有任何地方的代码段文件夹。

安装php7时出了什么问题?为什么我没有这个文件夹和conf文件?

感谢。

0 个答案:

没有答案