vagrant的学习 之 ThinkPHP3.2

vagrant的学习 之 ThinkPHP3.2


(1)在web目录下新建tp32目录:

cd /home/www/
mkdir tp32

(2)下载框架

我从ThinkPHP官网下载了ThinkPHP_3.2.3_full.zip,然后上传到虚拟机的里,解压到新建的tp32目录里。


(3)添加虚拟主机域名:

在nginx的配置文件里新建配置文件:

cd /etc/nginx/conf.d/
touch tp32.conf

编辑:sudo vim tp32.conf

server{
    server_name study.tp32.com;
    root /home/www/tp32;
    index index.php index.html;
    location / {
        if ( -f $request_filename){
            break;

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


    location ~ \.php{
        set $script $uri;
        set $path_info "";
        if ($uri ~ "^(.+\.php)(/.+)"){
            set $script $1;
            set $path_info $2;
        }
        include fastcgi_params;
        fastcgi_pass 127.0.0.1:9000;
        fastcgi_param PATH_INFO $path_info;
        fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name;
        fastcgi_param SCRIPT_NAME $script;
        try_files $uri = 404;
    }

}

重写规则可以参照ThinkPHP3.2完全开发手册【部署】-->【URL重写】:

http://document.thinkphp.cn/manual_3_2.html#url_rewrite

修改HOSTS文件:

sudo vim /etc/hosts

增加一行:

IP地址  study.tp32.com

重启nginx后,然后在本地机器上,访问 study.tp32.com,可以看到 欢迎使用 ThinkPHP 的界面。

重写配置好之后就可以以常见的url模式访问了:http://study.tp32.com/Home/Index/index。 


总结:

  编写nginx重写规则后,修改ThinkPHP的配置项 URL_MODEL 后好像就没区别了;

  对重写的规则一知半解,需要深入学习。


欢迎大家指点哦~


猜你喜欢

转载自www.cnblogs.com/gyfluck/p/9560051.html