每个外部站点都出现 nginx 502 Bad Gateway

每个外部站点都出现 nginx 502 Bad Gateway

我刚刚安装了 nginx,并按照官方网站上的指南使用 php5-fpm 进行设置,但就是不起作用。甚至没有 php 的默认网站也无法在我的服务器外运行。

已尝试listen = 127.0.0.1:7777,但listen = /var/run/php5-fpm.sock 均不起作用。

我可以http://localhost使用 lynx 在我的服务器上访问,但不能从其他地方访问(显然使用外部 IP)。

是的,php5-fpm守护进程正在运行,是的,端口(80 和 7777)已打开。

php-cgi也不要與此合作。

我的配置:

user www-data;
worker_processes 4;
pid /var/run/nginx.pid;

events {
        worker_connections 768;
        # multi_accept on;
}

http {

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

        ##
        # 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/x-javascript text/xml application/xml application/xml+rss text/javascript;

        ##
        # nginx-naxsi config
        ##
        # Uncomment it if you installed nginx-naxsi
        ##

        #include /etc/nginx/naxsi_core.rules;

        ##
        # nginx-passenger config
        ##
        # Uncomment it if you installed nginx-passenger
        ##

        #passenger_root /usr;
        #passenger_ruby /usr/bin/ruby;

        ##
        # Virtual Host Configs
        ##

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

        proxy_buffers 16 16k;
        proxy_buffer_size 32k;

        fastcgi_buffers 16 16k;
        fastcgi_buffer_size 32k;

        fastcgi_connect_timeout 300;
        fastcgi_send_timeout 300;
        fastcgi_read_timeout 300;
}

服务器配置: (符号链接到 sites-enabled)

server
{
  server_name skilloverflow.de *.skilloverflow.de;
  root /var/www/blog.skilloverflow.de/htdocs;

  index index.php;

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

  location = /favicon.ico {
    log_not_found off;
    access_log off;
  }

  location = /robots.txt {
    allow all;
    log_not_found off;
    access_log off;
  }

  location / {
    # This is cool because no php is touched for static content.
    # include the "?$args" part so non-default permalinks doesn't break when using query string
    try_files $uri $uri/ /index.php?$args;
  }

  location ~ [^/]\.php(/|$) {
    fastcgi_split_path_info ^(.+?\.php)(/.*)$;
    if (!-f $document_root$fastcgi_script_name) {
      return 404;
    }

    fastcgi_pass 127.0.0.1:7777;
    fastcgi_index index.php;
    include fastcgi_params;
  }

  location ~* \.(js|css|png|jpg|jpeg|gif|ico)$ {
    expires max;
    log_not_found off;
  }

  # deny access to apache .htaccess files
  location ~ /\.ht
  {
    deny all;
  }

  # deny access to apache .htaccess files
  location ~ /\.ht
  {
    deny all;
  }
}

PHP版本:5.4.17-1
nginx版本:1.2.1
Debian 6.0.7
Linux 2.6.32

编辑:Lighttpd 仍然安装着,这有关系吗?但它没有运行。 编辑2:没有生成任何错误或访问日志。它们都是空的。

答案1

如果您升级到 PHP 5.5.12,则打开 /etc/php5/fpm/pool.d/www.conf 并取消注释以下 listen 指令:

listen.owner = www-data
listen.group = www-data
listen.mode = 0660

然后重新启动 php5-fpm。

相关内容