nginx+ci

阿紫 posted @ 2012年11月28日 20:07 in php , 1742 阅读

    话说在/application/controllers下写了个hello.php,然后呢,在hello.php里写了个test方法欲输出hello world,可是呢,当我通过http://localhost/ci/index.php/hello/test访问时,却出现404。原因呢,nginx配置。好吧,废话就不多说了(其实也不会说),直接上正确的配置。

    

server
{
        listen       80;
        server_name  localhost;
        index index.php index.htm index.html;
        root  /www/php_example/;

        #limit_conn   crawler  20;   

        location / {
             index index.php index.html; 
       
             if (!-e $request_filename) {
                 rewrite ^/(.*)$ /index.php/$1 last;
             }   
        }

        location ~ .*\\.(php|php5)?$
        {       
              #fastcgi_pass  unix:/tmp/php-cgi.sock;
              fastcgi_pass  127.0.0.1:9000;
              fastcgi_index index.php;     
              include /etc/nginx/fastcgi_params;
              fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name;
        }

        location ~ .*\\.(php|php5)?($|/) {
               set $script $uri;
               set $path_info "";

               if ($uri ~ "^(.+.php)(/.+)") {
                     set $script $1;
                     set $path_info $2;
               }

              fastcgi_pass 127.0.0.1:9000;
              fastcgi_index index.php;
              fastcgi_param SCRIPT_FILENAME $document_root$script;
              fastcgi_param SCRIPT_NAME $script;
              fastcgi_param PATH_INFO $path_info;

       }

 }
  • 无匹配

登录 *


loading captcha image...
(输入验证码)
or Ctrl+Enter