AskOverflow.Dev

AskOverflow.Dev Logo AskOverflow.Dev Logo

AskOverflow.Dev Navigation

  • 主页
  • 系统&网络
  • Ubuntu
  • Unix
  • DBA
  • Computer
  • Coding
  • LangChain

Mobile menu

Close
  • 主页
  • 系统&网络
    • 最新
    • 热门
    • 标签
  • Ubuntu
    • 最新
    • 热门
    • 标签
  • Unix
    • 最新
    • 标签
  • DBA
    • 最新
    • 标签
  • Computer
    • 最新
    • 标签
  • Coding
    • 最新
    • 标签
主页 / server / 问题 / 389647
Accepted
Bartosz Kowalczyk
Bartosz Kowalczyk
Asked: 2012-05-17 05:27:16 +0800 CST2012-05-17 05:27:16 +0800 CST 2012-05-17 05:27:16 +0800 CST

Nginx:502 错误网关

  • 772

我尝试安装 nginx。我以前用 lighttpd 但现在必须安装 nginx。你能帮我配置nginx吗?

我使用 debian 6。我的nginx.conf:

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;

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

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

    ##
    # Gzip Settings
    ##

    gzip on;
    gzip_disable "msie6";

    ##
    # Virtual Host Configs
    ##

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

我的网站启用/默认看起来像

server {
    listen   80; ## listen for ipv4; this line is default and implied
    #listen   [::]:80 default ipv6only=on; ## listen for ipv6

    root /var/www; #!
    index index.php index.html index.htm; #1
    access_log      /var/log/nginx/access.log info;
    error_log       /var/log/nginx/error.log info;

    # Make site accessible from http://localhost/
    server_name localhost;

    location / {
            # First attempt to serve request as file, then
            # as directory, then fall back to index.html
            autoindex on;
            # Uncomment to enable naxsi on this location
            # include /etc/nginx/naxsi.rules
    }

    location /doc/ {
            alias /usr/share/doc/;
            autoindex on;
            allow 127.0.0.1;
            deny all;
    }

    location ~ \.php$ {
            fastcgi_split_path_info ^(.+\.php)(/.+)$;
            # NOTE: You should have "cgi.fix_pathinfo = 0;" in php.ini

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

    # deny access to .htaccess files, if Apache's document root
    # concurs with nginx's one

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

我添加到php.ini

cgi.fix_pathinfo = 0;     

    

php5-cgi 运行为

spawn-fcgi 127.0.0.1 -p 9000 -u www-data -f /usr/bin/php5-cgi

但是我收到502 错误(错误的网关)
我/var/log/说

2012/05/16 15:35:25 [error] 13427#0: *12 connect() failed (111: Connection refused) while connecting to upstream, client: 127.0.0.1, server: localhost, request: "GET /ndex.php HTTP/1.1", upstream: "fastcgi://127.0.0.1:9000", host: "localhost"

我没有运行sqpwn-fcgi=>php-cgi没有在监听端口9000。

configuration nginx 502-error
  • 2 2 个回答
  • 13623 Views

2 个回答

  • Voted
  1. Best Answer
    mgorven
    2012-05-17T09:20:21+08:002012-05-17T09:20:21+08:00

    PHP 要么未运行,要么正在运行但未侦听该套接字。检查它是否正在运行ps -eF | grep php,并且正在侦听netstat -tlpn | grep :9000。检查来自 PHP 的错误消息/var/log/syslog或者它自己的/var/log/.

    • 3
  2. Hannes
    2012-05-17T05:53:43+08:002012-05-17T05:53:43+08:00

    你在 nginx 框的错误日志中看到任何错误吗?(可能在 /var/log/nginx/ 的某处)这可能有助于发现问题。

    --

    好吧,我错过了日志中的部分。我认为您的 fastcgi 配置不正确...

    • 0

相关问题

  • 小型企业的服务器虚拟化/RAID 配置

  • httpd.conf 用于不区分大小写的文件服务

  • Windows Server 2003 DNS 添加的 CNAME 不起作用

  • 我应该使用什么策略在 linux 上安装 smtp 服务器?用于多线程服务

  • 为什么我的站点在配置为直通身份验证时使用 IUSR 帐户?

Sidebar

Stats

  • 问题 205573
  • 回答 270741
  • 最佳答案 135370
  • 用户 68524
  • 热门
  • 回答
  • Marko Smith

    新安装后 postgres 的默认超级用户用户名/密码是什么?

    • 5 个回答
  • Marko Smith

    SFTP 使用什么端口?

    • 6 个回答
  • Marko Smith

    命令行列出 Windows Active Directory 组中的用户?

    • 9 个回答
  • Marko Smith

    什么是 Pem 文件,它与其他 OpenSSL 生成的密钥文件格式有何不同?

    • 3 个回答
  • Marko Smith

    如何确定bash变量是否为空?

    • 15 个回答
  • Martin Hope
    Tom Feiner 如何按大小对 du -h 输出进行排序 2009-02-26 05:42:42 +0800 CST
  • Martin Hope
    Noah Goodrich 什么是 Pem 文件,它与其他 OpenSSL 生成的密钥文件格式有何不同? 2009-05-19 18:24:42 +0800 CST
  • Martin Hope
    Brent 如何确定bash变量是否为空? 2009-05-13 09:54:48 +0800 CST
  • Martin Hope
    cletus 您如何找到在 Windows 中打开文件的进程? 2009-05-01 16:47:16 +0800 CST

热门标签

linux nginx windows networking ubuntu domain-name-system amazon-web-services active-directory apache-2.4 ssh

Explore

  • 主页
  • 问题
    • 最新
    • 热门
  • 标签
  • 帮助

Footer

AskOverflow.Dev

关于我们

  • 关于我们
  • 联系我们

Legal Stuff

  • Privacy Policy

Language

  • Pt
  • Server
  • Unix

© 2023 AskOverflow.DEV All Rights Reserve