当前位置: > Linux服务器 > nginx >

nginx对thinkphp支持配置文件修改

时间:2016-01-07 00:42来源:linux.it.net.cn 作者:IT
nginx 配置目录:/usr/local/nginx/conf/vhost

配置文件内容:

server

        {

                listen       80;

                server_name yang.xxx.com;

                index index.html index.htm index.php;

                root  /data0/htdocs/xxx/liu;

                location / {


                if (!-e $request_filename)

                        {

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

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

                        }

                }

                #location ~ .*.(php|php5)?$

                location ~ .php

                        {

                                try_files $uri =404;

                                fastcgi_pass  unix:/tmp/php-cgi.sock;

                                fastcgi_index index.php;

                                include fcgi.conf;

                                set $path_info "";


                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;


}



                location /status {

                        stub_status on;

                        access_log   off;

                }


                location ~ .*.(gif|jpg|jpeg|png|bmp|swf)$

                        {

                                expires      30d;

                        }


                location ~ .*.(js|css)?$

                        {

                                expires      12h;

                        }


                access_log  /home/wwwlogs/access.log  access;

        }


注意事项:

location / {


                if (!-e $request_filename)

                        {

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

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

                        }

                }

if放置的位置要在location /  里面


检查配置文件:/usr/nginx/sbin/nginx -t

重启nginx:/usr/nginx/sbin/nginx -s reload

(责任编辑:IT)
------分隔线----------------------------
栏目列表
推荐内容