Nginx支持thinkphp pathinfo模式

Nginx默认不支持thinkphp的pathinfo 模式,无奈只能修改nginx配置。修改后的配置如下:

1.nginx.conf:


user  apache apache;

worker_processes  16;

worker_cpu_affinity auto;

pid        /var/run/nginx.pid;

worker_rlimit_nofile 51200;

events {

    use epoll;

    worker_connections  51200;

}

http {

    include       mime.types;

    default_type  application/octet-stream;

    #charset gb2312;

    charset utf-8;

    server_names_hash_bucket_size 128;

    client_max_body_size 10m;

    log_format main ‘$time_local\t$server_addr\t$request_uri\t$query_string\t$request_time\t$remote_addr\t‘

                   ‘$http_x_forwarded_for\t$http_user_agent\t‘

                   ‘$http_cookie\t$http_referer\t$server_name\t$status‘;

    access_log on;

    fastcgi_connect_timeout 300;

    fastcgi_send_timeout 300;

    fastcgi_read_timeout 300;

    fastcgi_buffer_size 128k;

    fastcgi_buffers 4 128k;

    fastcgi_busy_buffers_size 128k;

    fastcgi_temp_file_write_size 128k;

    fastcgi_intercept_errors on;

    gzip on;

    gzip_min_length  1k;

    gzip_buffers     16 32k;

    gzip_http_version 1.1;

    gzip_types  text/plain application/x-javascript text/css application/xml;

    include conf.d/*;

}


2.fastcgi.conf

fastcgi_pass  127.0.0.1:9000;

fastcgi_index index.php;

fastcgi_param  SCRIPT_FILENAME    $document_root$fastcgi_script_name;

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_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  HTTPS              $https if_not_empty;


fastcgi_param  GATEWAY_INTERFACE  CGI/1.1;

fastcgi_param  SERVER_SOFTWARE    nginx/$nginx_version;


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;


3.conf.d/vhost.conf:

 

server {

        listen       80;

        index index.php;

        root /data/www/wwwroot/;

        #location ~ .*\.php?$ {

        #    include     fastcgi.conf;

        #    access_log  /var/log/nginx/vhost_access.log;

        #}

        location / {      

            if (!-e $request_filename) {

                rewrite  ^/(.*)$  /index.php/$1  last;

                break;

           }

        }

  

        location ~ \.php {

            include     fastcgi.conf;

            set $real_script_name $fastcgi_script_name;

            if ($fastcgi_script_name ~ "^(.+?\.php)(/.+)$") {

                set $real_script_name $1;

                set $path_info $2;

            }

            fastcgi_param SCRIPT_FILENAME $document_root$real_script_name;

            fastcgi_param SCRIPT_NAME $real_script_name;

            fastcgi_param PATH_INFO $path_info;

        }

  }


Nginx支持thinkphp pathinfo模式,古老的榕树,5-wow.com

郑重声明:本站内容如果来自互联网及其他传播媒体,其版权均属原媒体及文章作者所有。转载目的在于传递更多信息及用于网络分享,并不代表本站赞同其观点和对其真实性负责,也不构成任何其他建议。