cleey
望着那一丝海线,若隐若现。落日下的海霞,数不尽的美,看不完的醉
nginx+php-fpm+thinkphp网站配置文件

如何使用nginx配置完成网站的访问,这里举出nginx获取请求转交给php-fpm处理使用thinkphp框架项目的配置文件:

thinkphp配置文件需要隐藏index.php.

server {
        listen 80;  # 端口
        server_name cleey.com www.cleey.com; # 网站域名 多个使用空格分开
        set $web_root /web/cleey; # 网站访问主目录
        # charset               utf-8;
        access_log              /var/log/nginx/cleey.access.log     main; # 日志
        error_log               /var/log/nginx/cleey.error.log      warn; # 日志
        autoindex               on;
        index                   index.php index.html; # 默认访问文件
        root                    $web_root;
        error_page 404 = /index.php; # 错误文件跳转
        # 都指向一个域名
        if ($host != 'www.cleey.com') {
                rewrite ^/(.*)$ /$1 permanent;
        }

        # thinkphp中重写加上 index.php
        location / {
                root            $web_root;
                #access_log      vim /var/log/nginx/cleey.access.log main;
                if (!-e $request_filename) {  
                        rewrite  ^/(.*)$  /index.php/$1  last;  
                        break;  
                }  
        }
        # 图片访问
        location ~* ^(/images|/Static).+.(jpg|jpeg|css|gif|png|ico) {
                root                    $web_root;
                access_log              off;
                expires                 10d;
        }
        # 交给php-fpm处理请求
        location ~ \.php($|/) {
                include                 fastcgi_params;
                #include                 fastcgi_params.default;
                fastcgi_pass            127.0.0.1:9000;
                fastcgi_index           index.php;
                #fastcgi_index           index.php?IF_REWRITE=1;

                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_NAME $real_script_name;
                fastcgi_param PATH_INFO $path_info;

                fastcgi_param           SCRIPT_FILENAME $web_root$fastcgi_script_name;
        }

}
<< 上一篇 实时推送技术的概念及实例 百度脑图 下一篇 >>
文章标签
随意 | Created At 2014 By William Clinton | Contact Me: 1619488373@qq.com | 蜀ICP备14002619号 |