along 发表于 2014-2-11 15:55:10

求助,无法执行php。

我想用UA判断不同的客户端,然后访问不同的目录。
html文档没问题。但这样子配置之后无法执行php文件。显示404。
error log没显示任何信息。
access log显示的是正常的404回应。
log_formatdomain.com'$remote_addr - $remote_user [$time_local] "$request" '
             '$status $body_bytes_sent "$http_referer" '
             '"$http_user_agent" $http_x_forwarded_for';
server
      {
                listen       80;
                server_name domain.com;
                #index index.html index.htm index.php default.html default.htm default.php;
                #root/mnt/resource/domain.com/;
                location / {
                        root/mnt/resource/domain.com/;
                        if ($http_user_agent ~* (mobile|nokia|iphone|ipad|android|samsung|htc|blackberry)){
                              root/mnt/resource/domain.com/v7/;
                              #indexindex.htmlindex.htm;
                        }
                        index index.php index.html;
                }

                include none.conf;
                location ~ .*\.(php|php5)?$
                        {
                              try_files $uri =404;
                              fastcgi_passunix:/tmp/php-cgi.sock;
                              fastcgi_index index.php;
                              include fcgi.conf;
                        }

                #location ~ .*\.(gif|jpg|jpeg|png|bmp|swf)$
                #       {
                #               expires      1h;
                #       }

                #location ~ .*\.(js|css)?$
                #       {
                #               expires      1h;
                #       }

                access_log/mnt/resource/domain.com/log.log1;
                error_log /mnt/resource/domain.com/error.logdebug;
      }

需要怎么改动?谢谢。

[ 本帖最后由 along 于 2014-2-11 15:58 编辑 ]

along 发表于 2014-2-11 16:04:50

同台服务器,其他网站正常执行php。

licess 发表于 2014-2-11 19:17:31

前面root的注释去掉

along 发表于 2014-2-11 20:11:08

#root/mnt/resource/domain.com/;
                location / {
                        root/mnt/resource/domain.com/;

第一个root启用,location里的root删掉。
这样设置之后,执行php的时候,访问domain.com/1.php时(v7目录同样有1.php),会直接访问到/domain.com/目录下的1.php,而无法根据UA来判断。。。
可有设置错误的地方?
谢谢。

along 发表于 2014-2-11 20:22:30

另外
                #location ~ .*\.(gif|jpg|jpeg|png|bmp|swf)$
                #       {
                #               expires      1h;
                #       }

                #location ~ .*\.(js|css)?$
                #       {
                #               expires      1h;
                #       }
如果取消掉#号取用这两块的话,UA手机端访问的时候,读取的图片、样式路径都会是domain.com目录而不是v7目录的。

licess 发表于 2014-2-12 09:57:22

php解析的里面也加上一个location里面的判断ua的代码

下面的图片缓存同上

along 发表于 2014-2-12 11:09:16

已经搞定。谢谢。。。
页: [1]
查看完整版本: 求助,无法执行php。