因为最近开始整一些新的框架学习 以前接触过tp3 但是时间太久了 然后就想着在学学tp5
自己的系统是mac 的 所以自带了一个apache composer安装完tp5之后很省心 也不用什么配置就成功了 然后传项目到git上 在另外一台ubuntu服务器上把代码 git pull 下来 就开始了填坑之旅
1.首先肯定是nginx 配置文件的配置
location / {
root html/thinkphp/public/;index index.html index.htm;
# 新增
rewrite ^(.*)$ /index.php?s=/$1 last;
break;
}
}
location ~\.php {
root html/thinkphp/public/; #根据自己环境配置
# fastcgi_pass 127.0.0.1:9000;
fastcgi_pass unix:/run/php/php7.1-fpm.sock; #根据自己环境配置
fastcgi_index index.php;
#新增
fastcgi_split_path_info ^(.+\.php)(.*)$;
fastcgi_param PATH_INFO $fastcgi_path_info;
fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name;
include fastcgi_params;
}
2.配置好之后 确实目录都是可以访问了 这个时候 我增加了index下另外一个控制器
php think make:controller index/test
生成文件之后确怎么也访问不到test下面的方法 找了半天之后才发现 tp5下的控制器必须大写 则删除 之前的test.php
php think make:controller index/Test 可以访问成功