nginx php-fpm 无法完全正常工作

nginx php-fpm 无法完全正常工作

我正在nginx-1.6.2_1,2使用php5-5.4.36

# uname -a
FreeBSD X.X.X 9.2-RELEASE-p5 FreeBSD 9.2-RELEASE-p5 #0 r265974: Wed May 14 07:57:04 PDT 2014     [email protected]:/usr/obj/usr/src/sys/R610  amd64
# 

nginx

# cat X.conf 
server {
    listen      X.X.X.X:80;
    server_name X;
    root        /home/X/X/;
    index       index.php;
    include     _includes/_location-php.include;
    include     _includes/4XX.include;
}
# cat _location-php.include 
location ~ \.php$ {
    include fastcgi_params;
    fastcgi_intercept_errors on;
    fastcgi_pass    unix:/var/run/php-fpm.sock;
    fastcgi_param   SCRIPT_FILENAME $request_filename;
}
# 

问题是:每当我点击/index.php/browse.php

# curl -I http://X/index.php
HTTP/1.1 200 OK
Server: nginx/1.6.2
Date: Tue, 20 Jan 2015 17:07:12 GMT
Content-Type: text/html
Content-Length: 7219
Connection: keep-alive
Set-Cookie: s=oa6u7nscersjad58fcfgk98174; path=/
Last-Modified: Wed, 31 Dec 2014 07:06:32 GMT
Cache-Control: no-store, no-cache, must-revalidate
Cache-Control: post-check=0, pre-check=0
Pragma: no-cache

# curl -I http://X/browse.php   
HTTP/1.1 200 OK
Server: nginx/1.6.2
Date: Tue, 20 Jan 2015 17:07:16 GMT
Content-Type: application/octet-stream
Content-Length: 50107
Last-Modified: Wed, 31 Dec 2014 07:06:12 GMT
Connection: keep-alive
ETag: "54a3a064-c3bb"
Accept-Ranges: bytes

# 

/index.php按预期工作并/browse.php返回 PHP 代码。

我也创建了phpinfo.php它并将其放置在根目录中,它可以按预期工作。

# curl -I http://X/phpinfo.php
HTTP/1.1 200 OK
Server: nginx/1.6.2
Date: Tue, 20 Jan 2015 17:16:05 GMT
Content-Type: text/html
Connection: keep-alive

# 

答案1

...实施此项后,该行为开始发生:

在nginx中,位置正则表达式返回错误410? - 代码日志

重新调整后,它现在可以按预期工作:

# cat X.conf 
server {
        listen      X.X.X.X:80;
    server_name X;
    root        /home/X/X/;
    index       index.php;
    location ~ \.php$ {
        include     _includes/_fastcgi.include;
    }
    location = /browse.php {
        if ($query_string ~* ^u=http) {
            return 410;
        }
        include     _includes/_fastcgi.include;
    }
}
#

相关内容