1、composer执行以下命令,安装命名为 tp_test  目录的tp6稳定版本

  composer create-project topthink/think tp_test

2、安装多应用模式扩展 think-multi-app  注意此处获取位置不能再获取tp6目录的位置执行,应进入项目目录,我前面项目目录在tp,所以需要进入tp文件夹中获取扩展,如果使用phpstorm打开可直接在左下角终端执行

  composer require topthink/think-multi-app 

3、删除app目录下的所有文件 (必须删)

4、修改配置文件开启多应用模式,在config/app.php文件下增加以下内容

  // 设置默认应用名称 

  1. 'default_app' => 'home',
  2.  // 开启自动多模式
    'auto_multi_app' => true,
  3.  // 开启应用快速访问
    'app_express' => false,

5、创建demo应用目录

  php think build 项目名

    

  再在app目录下创建多应用,路由,中间件等配置也在对应的项目目录下创建

     

 

 

 6、配置伪静态

  Apache:

<IfModule mod_rewrite.c>
Options +FollowSymlinks -Multiviews
RewriteEngine On

RewriteCond %{REQUEST_FILENAME} !-d
RewriteCond %{REQUEST_FILENAME} !-f
#RewriteRule ^(.*)$ index.php/$1 [QSA,PT,L]
RewriteRule ^(.*)$ index.php [L,E=PATH_INFO:$1]
</IfModule>

 

  nginx:

  

location / {
try_files $uri $uri/ /index.php?$query_string;
index index.html index.htm index.php;
autoindex on;
if (!-e $request_filename) {
rewrite ^(.*)$ /index.php?s=/$1 last;
break;
}
}