免费注册 查看新帖 |

Chinaunix

  平台 论坛 博客 文库
最近访问板块 发新帖
查看: 8019 | 回复: 3
打印 上一主题 下一主题

[Web] 关于nginx虚拟目录的PHP文件不能被运行 [复制链接]

论坛徽章:
0
跳转到指定楼层
1 [收藏(0)] [报告]
发表于 2008-10-24 04:17 |只看该作者 |倒序浏览
网站
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;
#               }
}


官方教程被翻个遍了还没有解决方案

论坛徽章:
0
2 [报告]
发表于 2008-10-24 09:26 |只看该作者

论坛徽章:
0
3 [报告]
发表于 2008-10-24 15:35 |只看该作者
原帖由 xi2008wang 于 2008-10-24 09:26 发表
http://www.xjtuer.com/php-fastcgi-nginx-alias/

看看可不可以



这个方案可以是可以,但只能解析虚假目录,其它目录里的PHP文件就不能解析了

论坛徽章:
0
4 [报告]
发表于 2008-10-24 16:35 |只看该作者
404的话有没有可能是,目录权限问题?
或者是fastcgi_param  SCRIPT_FILENAME设置的问题?
您需要登录后才可以回帖 登录 | 注册

本版积分规则 发表回复

  

北京盛拓优讯信息技术有限公司. 版权所有 京ICP备16024965号-6 北京市公安局海淀分局网监中心备案编号:11010802020122 niuxiaotong@pcpop.com 17352615567
未成年举报专区
中国互联网协会会员  联系我们:huangweiwei@itpub.net
感谢所有关心和支持过ChinaUnix的朋友们 转载本站内容请注明原作者名及出处

清除 Cookies - ChinaUnix - Archiver - WAP - TOP