2013-10-28 34 views
0

我想在我的Nginx服務器上設置我的Cakephp項目。Nginx不通過request_query CakePhP

現在一切正常,但有問題。

當過我嘗試通過paramters如mydomain.com/cake/users/view?searchvalue=test

它不工作。因爲沒有發送查詢值(即它們被刪除,空或不存在)。

現在我不知道如果我的htaccess的Cake這就是干擾,如果它是我的服務器

(所以爲什麼我在Stackoverflow而不是ServerFault發佈此,請注意,如果你認爲這應該是上服務器故障,而不是我將刪除它,去那裏)。

這裏是我的Nginx的文件:

server { 
    listen  80; 
    server_name my-domain.com; 
    return 301 http://www.my-domain.com$request_uri; 
} 

server{ 
    listen  80 default; 
    server_name  www.my-domain.com; 


     location ~ [^/]\.php(/|$) { 
       fastcgi_split_path_info ^(.+?\.php)(/.*)$; 
       if (!-f $document_root$fastcgi_script_name) { 
         return 404; 
       } 

       fastcgi_pass 127.0.0.1:9000; 
       fastcgi_index index.php; 
       include  /etc/nginx/fastcgi_params; 
     #include fastcgi_params; 
     } 


    location ~ ^/cake/(.+)$ { 
     index index.php; 

    set $val $1; 

     try_files $uri $uri/ /cake/app/webroot/$val /cake/app/webroot/index.php/$val; 

    } 

請告訴我,如果你需要了解更多信息!

下面是一些額外的信息這是它試圖去my-domain.com/admin/test/servertest?laura這是當我回聲服務器變量時打印出:

array (
    'USER' => 'apache', 
    'HOME' => '/var/www', 
    'FCGI_ROLE' => 'RESPONDER', 
    'QUERY_STRING' => ' ', <---- **this is the problem** 
    'REQUEST_METHOD' => 'GET', 
    'CONTENT_TYPE' => '', 
    'CONTENT_LENGTH' => '', 
    'SCRIPT_FILENAME' => '/usr/share/nginx/html/cake/app/webroot/index.php', 
    'SCRIPT_NAME' => '/cake/app/webroot/index.php', 
    'PATH_INFO' => '', 
    'REQUEST_URI' => '/cake/admin/employees/servertest?laura', 
    'DOCUMENT_URI' => '/cake/app/webroot/index.php', 
    'DOCUMENT_ROOT' => '/usr/share/nginx/html', 
    'SERVER_PROTOCOL' => 'HTTP/1.1', 
    'GATEWAY_INTERFACE' => 'CGI/1.1', 
    'SERVER_SOFTWARE' => 'nginx/1.0.15', 
    'REMOTE_ADDR' => '**.**.***.***', 
    'REMOTE_PORT' => '53811', 
    'SERVER_ADDR' => '***.**.***.***', 
    'SERVER_PORT' => '80', 
    'SERVER_NAME' => 'www.my-domain.com', 
    'REDIRECT_STATUS' => '200', 
    'HTTP_HOST' => 'www.my-domain.com', 
    'HTTP_USER_AGENT' => 'Mozilla/5.0 (X11; Ubuntu; Linux x86_64; rv:24.0) Gecko/20100101 Firefox/24.0', 
    'HTTP_ACCEPT' => 'text/html,application/xhtml+xml,application/xml;q=0.9,*/*;q=0.8', 
    'HTTP_ACCEPT_LANGUAGE' => 'en-US,en;q=0.5', 
    'HTTP_ACCEPT_ENCODING' => 'gzip, deflate', 
    'HTTP_COOKIE' => 'bloglic_data[credentials]=Q2FrZQ%3D%3D.XG7at918B4h8lCRNBCdwg0Avi3ZNLdAn28Dl3vfOxaQkJAoJFYxZ0s1a%2Fp3RLB2%2B5krPCIBKFboN4y1X4lY4%2FFautJJ7ce6VyN%2BOgLFbR4KUzn5g7QGDlZS2YqB%2FbZ%2FghYfKzcZvzkYYkvtj9dQkozRMaUPWY8%2F910tf7fnpk8EFAQ%3D%3D; CAKEPHP=7c411r3pc7vhjk3vjqjoplmtk3', 
    'HTTP_CONNECTION' => 'keep-alive', 
    'PHP_SELF' => '/cake/app/webroot/index.php', 
    'REQUEST_TIME_FLOAT' => 1382965704.0475, 
    'REQUEST_TIME' => 1382965704, 
) 
+0

這個問題更適合於serverfault - [現有的問題+覆蓋這個問題的答案](http://serverfault.com/questions/231578/nginx-php-fpm-where-are-my-get-params/ 362924#362924) – AD7six

回答

1

Oblig改變這種atory if is evilhttp://wiki.nginx.org/IfIsEvil

貸pasela此:https://gist.github.com/pasela/3052624

# 
# nginx configuration example for CakePHP 2.x 
# 
server { 
    listen  80; 
    server_name cakephp2.example; 
    root   /var/www/cakephp2/app/webroot; 

    access_log /var/log/nginx/cakephp2.access.log; 
    error_log /var/log/nginx/cakephp2.error.log; 

    location/{ 
     index index.php; 
     try_files $uri $uri/ /index.php$is_args$args; 
    } 

    location ~ \.php$ { 
     include  fastcgi_params; 
     fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name; 
     fastcgi_pass 127.0.0.1:9000; 
    } 

    location ~ \.php/ { 
     include  fastcgi_params; 
     fastcgi_split_path_info ^(.+\.php)(/.*)$; 
     fastcgi_param PATH_INFO $fastcgi_path_info; 
     fastcgi_param PATH_TRANSLATED $document_root$fastcgi_path_info; 
     fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name; 
     fastcgi_pass 127.0.0.1:9000; 
    } 

    location = /favicon.ico { 
     log_not_found off; 
     access_log off; 
    } 

    location = /robots.txt { 
     log_not_found off; 
     access_log off; 
    } 

    #error_page 404    /404.html; 
    #location = /404.html { 
    # root /usr/share/nginx/html; 
    #} 

    # redirect server error pages to the static page /50x.html 
    # 
    error_page 500 502 503 504 /50x.html; 
    location = /50x.html { 
     root /usr/share/nginx/html; 
    } 

    # deny access to .htaccess files, if Apache's document root 
    # concurs with nginx's one 
    # 
    location ~ /(\.ht|\.user.ini|\.git|\.hg|\.bzr|\.svn) { 
     deny all; 
    } 

}

這就是我有,當我第一次安裝蛋糕mod_rewrite的問題後遇到。你可以改變一些東西,例如我使用unix socketfastcgi_pass而不是TCP/IP socket

1

試在try_files

/cake/app/webroot/index.php/$val; 

這個

/cake/app/webroot/index.php/$val$is_args$query_string;