再次出现Perl + nginx 403错误

时间:2015-07-31 12:40:40

标签: perl nginx

似乎永无止境的战斗让Perl和nginx玩得很好:(我已经设置了一个新的开发服务器。我不会厌烦你所有的细节,但足以说我安装了(通过apt-get );

sudo apt-get update && sudo apt-get upgrade
sudo apt-get install nginx
sudo apt-get install php5-cli php5-cgi spawn-fcgi php-pear
sudo apt-get install mysql-server php5-mysql
sudo apt-get install fcgiwrap

然后我使用:

配置了我的网站
server {

    listen   80;

    server_name site.net.net www.site.net.net;
    access_log /srv/www/site.net.net/logs/access.log;
    error_log /srv/www/site.net.net/logs/error.log;
    root /srv/www/site.net.net/www;

 location / {
        index  index.html index.htm;
    }

    location ~ \.php$ {
        try_files $uri =404;
        include /etc/nginx/fastcgi_params;
        fastcgi_pass 127.0.0.1:9000;
        fastcgi_index index.php;
        fastcgi_param SCRIPT_FILENAME /srv/www/site.net.net/www$fastcgi_script_name;
    }

    location ~ \.cgi$ {
            try_files $uri =404;
            gzip off;
            include /etc/nginx/fastcgi_params;
            fastcgi_pass unix:/var/run/fcgiwrap.socket;
            fastcgi_index index.cgi;
            fastcgi_param SCRIPT_FILENAME /srv/www/site.net.net/www/cgi-bin/$fastcgi_script_name;
        }

}

我已将配置文件sym链接到已启用的网站,以便在nginx上显示。然后我重新启动了nginx,并尝试了:

index.html - works fine
index.php - works fine
index.cgi - 403 error

我上次设法摸索了它,但我无法弄清楚我做了什么不同(我知道这是第一次配置的真猪)

error_log 中唯一显示的是:

2015/07/31 15:52:25 [error] 10434#0: *7 open() "/srv/www/site.net/www/favicon.ico" failed (2: No such file or directory), client: 81.174.134.xx, server: sitenet, request: "GET /favicon.ico HTTP/1.1", host: "site.net"

所以帮助不大:/

专家的任何建议?

更新

如果我将错误日志更新为" debug"等级,即:

error_log /srv/www/steampunkjunkiesdev.net/logs/error.log debug;

...下面是输出的内容(仅来自1个请求)。不确定那里有什么有用的东西吗?

Server: nginx/1.6.2
Date: Fri, 31 Jul 2015 15:11:49 GMT
Content-Type: text/html
Transfer-Encoding: chunked
Connection: keep-alive
Content-Encoding: gzip

2015/07/31 16:11:49 [debug] 3557#0: *1 write new buf t:1 f:0 0000000000F049D8, pos 0000000000F049D8, size: 185 file: 0, size: 0
2015/07/31 16:11:49 [debug] 3557#0: *1 http write filter: l:0 f:0 s:185
2015/07/31 16:11:49 [debug] 3557#0: *1 http output filter "/favicon.ico?"
2015/07/31 16:11:49 [debug] 3557#0: *1 http copy filter: "/favicon.ico?"
2015/07/31 16:11:49 [debug] 3557#0: *1 image filter
2015/07/31 16:11:49 [debug] 3557#0: *1 xslt filter body
2015/07/31 16:11:49 [debug] 3557#0: *1 http postpone filter "/favicon.ico?" 0000000000F04AF8
2015/07/31 16:11:49 [debug] 3557#0: *1 http gzip filter
2015/07/31 16:11:49 [debug] 3557#0: *1 malloc: 0000000000EED690:12288
2015/07/31 16:11:49 [debug] 3557#0: *1 gzip alloc: n:1 s:5936 a:8192 p:0000000000EED690
2015/07/31 16:11:49 [debug] 3557#0: *1 gzip alloc: n:512 s:2 a:1024 p:0000000000EEF690
2015/07/31 16:11:49 [debug] 3557#0: *1 gzip alloc: n:512 s:2 a:1024 p:0000000000EEFA90
2015/07/31 16:11:49 [debug] 3557#0: *1 gzip alloc: n:512 s:2 a:1024 p:0000000000EEFE90
2015/07/31 16:11:49 [debug] 3557#0: *1 gzip alloc: n:256 s:4 a:1024 p:0000000000EF0290
2015/07/31 16:11:49 [debug] 3557#0: *1 gzip in: 0000000000EF6EE8
2015/07/31 16:11:49 [debug] 3557#0: *1 gzip in_buf:0000000000F04AA8 ni:00000000006DC600 ai:116
2015/07/31 16:11:49 [debug] 3557#0: *1 malloc: 0000000000EF06A0:4096
2015/07/31 16:11:49 [debug] 3557#0: *1 deflate in: ni:00000000006DC600 no:0000000000EF06A0 ai:116 ao:4096 fl:0 redo:0
2015/07/31 16:11:49 [debug] 3557#0: *1 deflate out: ni:00000000006DC674 no:0000000000EF06A0 ai:0 ao:4096 rc:0
2015/07/31 16:11:49 [debug] 3557#0: *1 gzip in_buf:0000000000F04AA8 pos:00000000006DC600
2015/07/31 16:11:49 [debug] 3557#0: *1 gzip in: 0000000000EF6EF8
2015/07/31 16:11:49 [debug] 3557#0: *1 gzip in_buf:0000000000EF6E20 ni:00000000006DCDA0 ai:52
2015/07/31 16:11:49 [debug] 3557#0: *1 deflate in: ni:00000000006DCDA0 no:0000000000EF06A0 ai:52 ao:4096 fl:4 redo:0
2015/07/31 16:11:49 [debug] 3557#0: *1 deflate out: ni:00000000006DCDD4 no:0000000000EF0711 ai:0 ao:3983 rc:1
2015/07/31 16:11:49 [debug] 3557#0: *1 gzip in_buf:0000000000EF6E20 pos:00000000006DCDA0
2015/07/31 16:11:49 [debug] 3557#0: *1 free: 0000000000EED690
2015/07/31 16:11:49 [debug] 3557#0: *1 http chunk: 10
2015/07/31 16:11:49 [debug] 3557#0: *1 http chunk: 121
2015/07/31 16:11:49 [debug] 3557#0: *1 write old buf t:1 f:0 0000000000F049D8, pos 0000000000F049D8, size: 185 file: 0, size: 0
2015/07/31 16:11:49 [debug] 3557#0: *1 write new buf t:1 f:0 0000000000EF7058, pos 0000000000EF7058, size: 4 file: 0, size: 0
2015/07/31 16:11:49 [debug] 3557#0: *1 write new buf t:0 f:0 0000000000000000, pos 00000000006E0240, size: 10 file: 0, size: 0
2015/07/31 16:11:49 [debug] 3557#0: *1 write new buf t:1 f:0 0000000000EF06A0, pos 0000000000EF06A0, size: 121 file: 0, size: 0
2015/07/31 16:11:49 [debug] 3557#0: *1 write new buf t:0 f:0 0000000000000000, pos 00000000004B2EB8, size: 7 file: 0, size: 0
2015/07/31 16:11:49 [debug] 3557#0: *1 http write filter: l:1 f:1 s:327
2015/07/31 16:11:49 [debug] 3557#0: *1 http write filter limit 0
2015/07/31 16:11:49 [debug] 3557#0: *1 writev: 327
2015/07/31 16:11:49 [debug] 3557#0: *1 http write filter 0000000000000000
2015/07/31 16:11:49 [debug] 3557#0: *1 http copy filter: 0 "/favicon.ico?"
2015/07/31 16:11:49 [debug] 3557#0: *1 http finalize request: 0, "/favicon.ico?" a:1, c:1
2015/07/31 16:11:49 [debug] 3557#0: *1 set http keepalive handler
2015/07/31 16:11:49 [debug] 3557#0: *1 http close request
2015/07/31 16:11:49 [debug] 3557#0: *1 http log handler
2015/07/31 16:11:49 [debug] 3557#0: *1 free: 0000000000EF06A0
2015/07/31 16:11:49 [debug] 3557#0: *1 free: 0000000000000000
2015/07/31 16:11:49 [debug] 3557#0: *1 free: 0000000000F03B20, unused: 8
2015/07/31 16:11:49 [debug] 3557#0: *1 free: 0000000000EF6A40, unused: 2156
2015/07/31 16:11:49 [debug] 3557#0: *1 free: 0000000000F09E70
2015/07/31 16:11:49 [debug] 3557#0: *1 hc free: 0000000000000000 0
2015/07/31 16:11:49 [debug] 3557#0: *1 hc busy: 0000000000000000 0
2015/07/31 16:11:49 [debug] 3557#0: *1 reusable connection: 1
2015/07/31 16:11:49 [debug] 3557#0: *1 event timer add: 14: 65000:1438355574073
2015/07/31 16:11:49 [debug] 3557#0: *1 post event 0000000000F4A118
2015/07/31 16:11:49 [debug] 3557#0: *1 delete posted event 0000000000F4A118
2015/07/31 16:11:49 [debug] 3557#0: *1 http keepalive handler
2015/07/31 16:11:49 [debug] 3557#0: *1 malloc: 0000000000F09E70:1024
2015/07/31 16:11:49 [debug] 3557#0: *1 recv: fd:14 -1 of 1024
2015/07/31 16:11:49 [debug] 3557#0: *1 recv() not ready (11: Resource temporarily unavailable)
2015/07/31 16:11:49 [debug] 3557#0: *1 free: 0000000000F09E70

1 个答案:

答案 0 :(得分:4)

Eugh,我觉得自己现在像个白痴!在我的配置中,我有:

location ~ \.cgi$ {
    gzip off;
    include /etc/nginx/fastcgi_params;
    fastcgi_pass unix:/var/run/fcgiwrap.socket;
    fastcgi_index index.cgi;
    fastcgi_param SCRIPT_FILENAME /srv/www/site.net/www/cgi-bin$fastcgi_script_name;
}

然而,SCRIPT_FILENAME错误......应该是:

location ~ \.cgi$ {
    gzip off;
    include /etc/nginx/fastcgi_params;
    fastcgi_pass unix:/var/run/fcgiwrap.socket;
    fastcgi_index index.cgi;
    fastcgi_param SCRIPT_FILENAME /srv/www/site.net/www/$fastcgi_script_name;
}

(注意第2行到最后一行的丢失/ cgi-bin)。当你看到它时如此简单!只是想我会分享它,希望它能在将来某个时候帮助其他人。杜!