空白页 Nginx 1.10 Wordpress PHP7.0-FPM

空白页 Nginx 1.10 Wordpress PHP7.0-FPM

我已经搜索了几个小时。我发现了很多类似的情况,但不明白为什么我的不匹配。当我访问我的网址时,我收到 502 Bad Gateway 错误。现在使用当前设置,它只是一个空白页。我猜是找不到文件,但我找不到任何错误或缺失的东西。

我使用的是 Ubuntu 16.04 LTS、Nginx 1.10、PHP 7.0 FPM、MySQL。我还需要分享其他东西吗?感谢大家的帮助。

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/站点可用/默认

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"

答案1

如果你的配置文件有此行:

fastcgi_pass  127.0.0.1:9000;

在您的 /etc/php/7.0/fpm/pool.d/www.conf 中,有一行显示

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

那么你需要用

listen = 127.0.0.1:9000

保存文件并重新启动 php:

service php7.0-fpm restart

它应该可以工作!

相关内容