歡迎您光臨本站 註冊首頁

關於nginx虛擬目錄的PHP文件不能被運行

←手機掃碼閱讀     火星人 @ 2014-03-04 , reply:0

關於nginx虛擬目錄的PHP文件不能被運行

網站
http://192.168.1.10
根目錄為 /data/www/wwwroot
其中有個虛擬目錄URL為http://192.168.1.10/uc
地址為 /data/www/admin
發現凡是/data/www/admin里的PHP文件都報404錯誤


os: Freebsd 7.1 AMD64
php: 5.2.6
nginx : 0.6.32

php的php.ini沒有動過,默認值

nginx.con如下
user www www;
worker_processes  4;

#error_log  logs/error.log;
#error_log  logs/error.log  notice;
#error_log  logs/error.log  info;

pid        /var/run/nginx.pid;


events
{
        use kqueue;
    worker_connections  1024;
        
}


http {
    include       mime.types;
#    include       vhosts/php5.conf;
    default_type  application/octet-stream;

    #log_format  main  '$remote_addr - $remote_user [$time_local] $request '
    #                  '"$status" $body_bytes_sent "$http_referer" '
    #                  '"$http_user_agent" "$http_x_forwarded_for"';

    #access_log  logs/access.log  main;

    sendfile        on;
    #tcp_nopush     on;

    #keepalive_timeout  0;
    keepalive_timeout  65;

    #gzip  on;

    #=============vhosts config=============
    include vhosts/vhosts.conf;

    # another virtual host using mix of IP-, name-, and port-based configuration
    #
    #server {
    #    listen       8000;
    #    listen       somename:8080;
    #    server_name  somename  alias  another.alias;

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



    # HTTPS server
    #
    #server {
    #    listen       443;
    #    server_name  localhost;

    #    ssl                  on;
    #    ssl_certificate      cert.pem;
    #    ssl_certificate_key  cert.key;

    #    ssl_session_timeout  5m;

    #    ssl_protocols  SSLv2 SSLv3 TLSv1;
    #    ssl_ciphers  ALL:!ADH:!EXPORT56:RC4+RSA:+HIGH:+MEDIUM:+LOW:+SSLv2:+EXP;
    #    ssl_prefer_server_ciphers   on;

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

}


vhost/php5.conf如下
#fastcgi_pass  127.0.0.1:9980;
#fastcgi_index index.php;

fastcgi_param  GATEWAY_INTERFACE  CGI/1.1;
fastcgi_param  SERVER_SOFTWARE    nginx;
##new ac upload
fastcgi_pass_request_body on;
client_body_in_file_only clean;
fastcgi_param  REQUEST_BODY_FILE  $request_body_file;
##

fastcgi_param  QUERY_STRING       $query_string;
fastcgi_param  REQUEST_METHOD     $request_method;
fastcgi_param  CONTENT_TYPE       $content_type;
fastcgi_param  CONTENT_LENGTH     $content_length;

fastcgi_param  SCRIPT_FILENAME    $document_root$fastcgi_script_name;
fastcgi_param  PATH_INFO          $fastcgi_script_name;
fastcgi_param  SCRIPT_NAME        $fastcgi_script_name;
fastcgi_param  REQUEST_URI        $request_uri;
fastcgi_param  DOCUMENT_URI       $document_uri;
fastcgi_param  DOCUMENT_ROOT      $document_root;
fastcgi_param  SERVER_PROTOCOL    $server_protocol;

fastcgi_param  REMOTE_ADDR        $remote_addr;
fastcgi_param  REMOTE_PORT        $remote_port;
fastcgi_param  SERVER_ADDR        $server_addr;
fastcgi_param  SERVER_PORT        $server_port;
fastcgi_param  SERVER_NAME        $server_name;

# PHP only, required if PHP was built with --enable-force-cgi-redirect
fastcgi_param  REDIRECT_STATUS    200;


vhost/vhost.conf如下
server
{
listen 80;
server_name localhost;
        root    /data/www/wwwroot;
        index  index.html index.htm index.php;

        location /uc/
        {
        alias /data/www/admin/;
        index index.html index.htm index.php;
        }
        location ~ .*\.php?$
                {
                fastcgi_index  index.php;
                fastcgi_param  SCRIPT_FILENAME  $document_root$fastcgi_script_name;
                include vhosts/php5.conf;
                fastcgi_pass    127.0.0.1:9980;
                }
#       location ~^/uc/.*\php?$
#               {
#               fastcgi_index  index.php;
#                fastcgi_param  SCRIPT_FILENAME  $document_root$fastcgi_script_name;
#                include vhosts/php5.conf;
#                fastcgi_pass    127.0.0.1:9980;
#               }
}

官方教程被翻個遍了還沒有解決方案
《解決方案》

http://www.xjtuer.com/php-fastcgi-nginx-alias/

看看可不可以
《解決方案》

原帖由 xi2008wang 於 2008-10-24 09:26 發表 http://bbs3.chinaunix.net/images/common/back.gif
http://www.xjtuer.com/php-fastcgi-nginx-alias/

看看可不可以


這個方案可以是可以,但只能解析虛假目錄,其它目錄里的PHP文件就不能解析了
《解決方案》

404的話有沒有可能是,目錄許可權問題?
或者是fastcgi_param  SCRIPT_FILENAME設置的問題?

[火星人 ] 關於nginx虛擬目錄的PHP文件不能被運行已經有295次圍觀

http://coctec.com/docs/service/show-post-26778.html