Nginx – Blank Page Nginx 1.10 WordPress PHP7.0-FPM

nginxphp7Wordpress

I've been searching for hours. I've found so many similar cases and can't figure out why mine doesn't match. When I go to my web address I was getting a 502 Bad Gateway error. Now with the current setup, it's just a blank page. I'm guessing a file can't be found but I haven't been able to find any errors or things missing.

I'm on Ubuntu 16.04 LTS, Nginx 1.10, PHP 7.0 FPM, MySQL. Do I need to share anything else? Thanks to everyone for their help.

nginx.conf

user www-data;
worker_processes auto;
pid /run/nginx.pid;

events {
    worker_connections 768;
    # multi_accept on;
}

http {
    fastcgi_buffers 8 16k;
    fastcgi_buffer_size 32k;
    client_body_buffer_size 128k;
    ##
    # Basic Settings
    ##

    sendfile on;
    tcp_nopush on;
    tcp_nodelay on;
    keepalive_timeout 65;
    types_hash_max_size 2048;
    # server_tokens off;

    # server_names_hash_bucket_size 64;
    # server_name_in_redirect off;

    include /etc/nginx/mime.types;
    default_type application/octet-stream;

    ##
    # SSL Settings
    ##

    ssl_protocols TLSv1 TLSv1.1 TLSv1.2; # Dropping SSLv3, ref: POODLE
    ssl_prefer_server_ciphers on;

    ##
    # Logging Settings
    ##

    access_log /var/log/nginx/access.log;
    error_log /var/log/nginx/error.log;

    ##
    # Gzip Settings
    ##

    gzip on;
    gzip_disable "msie6";

    # gzip_vary on;
    # gzip_proxied any;
    # gzip_comp_level 6;
    # gzip_buffers 16 8k;
    # gzip_http_version 1.1;
    # gzip_types text/plain text/css application/json application/javascript text/xml application/xml application/xml+rss text/javascript;

    ##

    ##
    # Virtual Host Configs
    ##

    include /etc/nginx/conf.d/*.conf;
    include /etc/nginx/sites-enabled/*;

    client_max_body_size 100M;
}

/etc/nginx/sites-available/mysite.conf

server {
    server_name my site dot com;
    listen 443 ssl http2;
    listen [::]:443 ssl http2;

    ssl_certificate /etc/letsencrypt/live/mysite/fullchain.pem;
    ssl_certificate_key /etc/letsencrypt/live/mysite/privkey.pem;
    ssl_trusted_certificate /etc/letsencrypt/live/mysite/fullchain.pem;
    include /etc/nginx/snippets/ssl.conf;

    root /var/www/mysite;
    index index.php index.html index.htm;

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

    location ~ \.php$ {
            include /etc/nginx/fastcgi_params;
            fastcgi_pass  127.0.0.1:9000;
            fastcgi_index index.php;
            fastcgi_param SCRIPT_FILENAME $document_root/$fastcgi_script_name;
    }
    #location ~ \.php$ {
    #        try_files $uri =404;
    #        fastcgi_split_path_info ^(.+\.php)(/.+)$;
    #        fastcgi_pass unix:/var/run/php/php7.0-fpm.sock;
    #
    #        fastcgi_index index.php;
    #        fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name;
    #        include fastcgi_params;
    #}
  }

/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 my_IP;

  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;
  }
}

/var/log/php7.0-fpm.log

[17-Nov-2017 15:23:13] NOTICE: fpm is running, pid 26582
[17-Nov-2017 15:23:13] NOTICE: ready to handle connections
[17-Nov-2017 15:23:13] NOTICE: systemd monitor interval set to 10000ms
[17-Nov-2017 15:37:03] NOTICE: Terminating ...
[17-Nov-2017 15:37:03] NOTICE: exiting, bye-bye!
[17-Nov-2017 15:37:03] NOTICE: configuration file /etc/php/7.0/fpm/php-fpm.conf test is successful

[17-Nov-2017 15:37:03] NOTICE: fpm is running, pid 26738
[17-Nov-2017 15:37:03] NOTICE: ready to handle connections
[17-Nov-2017 15:37:03] NOTICE: systemd monitor interval set to 10000ms

/var/log/nginx/error.log

2017/11/17 15:55:47 [crit] 26937#26937: *373 connect() to unix:/var/run/php/php7.0-fpm.sock failed (2: No such file or directory) while connecting to upstream, client: 141.8.142.17, server: mysite, request: "GET /wp-content/uploads/2014/09/image005.jpg HTTP/1.1", upstream: "fastcgi://unix:/var/run/php/php7.0-fpm.sock:", host: "mysite"
2017/11/17 18:16:35 [crit] 26966#26966: *671 connect() to unix:/run/php/php7.0-fpm.sock failed (2: No such file or directory) while connecting to upstream, client: IP, server: my_IP, request: "GET /error.php HTTP/1.1", upstream: "fastcgi://unix:/run/php/php7.0-fpm.sock:", host: "my_IP"

Best Answer

if your config file has this line:

fastcgi_pass  127.0.0.1:9000;

and in your /etc/php/7.0/fpm/pool.d/www.conf you have at line where it shows

listen = /run/php/php7.0-fpm.sock

then you need to replace it with

listen = 127.0.0.1:9000

save file and restart php:

service php7.0-fpm restart

It should work!