### 1、虚拟主机设置 路径:```D:\wamp64\bin\apache\apache2.4.27\conf\extra``` ``` <VirtualHost *:80> DocumentRoot "F:\www\TP5.1\2.0\public" ServerName tp5-2.com ServerAlias tp5-2.com #ErrorLog "logs/Domain-error.log" #CustomLog "logs/Domain-access.log" combined </VirtualHost> ``` ### 2、Hosts文件设置 路径:```C:\Windows\System32\drivers\etc\HOSTS``` ``` 127.0.0.1 tp5-2.com ``` ### 3、对模板进行全局替换配置 >[danger] 首先,我们需要对模板输出替换进行设置,可以直接在源码根目录的 ```config/template.php``` 配置文件中添加: ``` // 对模板进行全局替换配置 'tpl_replace_string' => [ '__STATIC__'=>'/static', ] ``` ### 4、路由设置 >[info] 路由文件在源码根目录的 ```route``` 文件夹里面,有一个 ```route.php``` 文件,打开它。 代码如下: ``` <?php // +---------------------------------------------------------------------- // | ThinkPHP [ WE CAN DO IT JUST THINK ] // +---------------------------------------------------------------------- // | Copyright (c) 2006~2018 http://thinkphp.cn All rights reserved. // +---------------------------------------------------------------------- // | Licensed ( http://www.apache.org/licenses/LICENSE-2.0 ) // +---------------------------------------------------------------------- // | Author: liu21st <liu21st@gmail.com> // +---------------------------------------------------------------------- use think\facade\Route; Route::rule('/', 'index/index/index'); // 栏目路由 Route::rule('cate/add','index/cate/add'); Route::rule('cate/edit/:id', 'index/cate/edit'); Route::rule('cate/del/:id', 'index/cate/del'); Route::rule('cate', 'index/cate/lst'); return [ ]; ``` ### 5、Session设置 >[info] Session 配置文件在源码根目录的 ```config``` 文件夹里面,有一个 ```session.php``` 文件,打开它。 代码如下: ``` <?php // +---------------------------------------------------------------------- // | ThinkPHP [ WE CAN DO IT JUST THINK ] // +---------------------------------------------------------------------- // | Copyright (c) 2006~2018 http://thinkphp.cn All rights reserved. // +---------------------------------------------------------------------- // | Licensed ( http://www.apache.org/licenses/LICENSE-2.0 ) // +---------------------------------------------------------------------- // | Author: liu21st <liu21st@gmail.com> // +---------------------------------------------------------------------- // +---------------------------------------------------------------------- // | 会话设置 // +---------------------------------------------------------------------- return [ 'id' => '', // SESSION_ID的提交变量,解决flash上传跨域 'var_session_id' => '', // SESSION 前缀 'prefix' => 'think', // 驱动方式 支持redis memcache memcached 'type' => '', // 是否自动开启 SESSION 'auto_start' => true, ]; ``` >[success] 至此,我们的项目配置也就配置完了