ThinkPHP5安装与配置步骤方法

1.配置Hosts文件
C:\Windows\System32\drivers\etc\hosts


2.D:\wamp\bin\apache\apache2.2.22\conf\httpd.conf
查找Include conf/extra/httpd-vhosts.conf,去掉前面的#号

3.配置Apache文件
D:\wamp\bin\apache\Apache2.2.17\conf\extra

 

 

[html] view plain copy
 
  1. <!-- 配置信息 -->  
  2. <VirtualHost *:80>  
  3.     ServerAdmin webmaster@dummy-host2.hleclerc-PC.ingenidev  
  4.     DocumentRoot "d:/wamp/www/think5/public"  
  5.     ServerName www.kmgfyy120.com  
  6.     ErrorLog "logs/dummy-host2.hleclerc-PC.ingenidev-error.log"  
  7.     CustomLog "logs/dummy-host2.hleclerc-PC.ingenidev-access.log" common  
  8. </VirtualHost>  

 

去除index.php路径
1、如果没有开启 URL_REWRITE,则你需要找到 Apache 中的 httpd.conf 这个配置文件,找到下面这行:


#LoadModule rewrite_module modules/mod_rewrite.so


把前面的警号去掉,然后继续找到下面这句:


2、AllowOverride None


将所有找到的以上语句都改为:AllowOverride All


以上修改完毕然后重启 Apache 服务器即可。


3、在应用的根目录下面新建一个 .htaccess 文件。在文件里面加入如下代码:
<IfModule mod_rewrite.c>
RewriteEngine on
RewriteCond %{REQUEST_FILENAME} !-d
RewriteCond %{REQUEST_FILENAME} !-f
RewriteRule ^(.*)$ index.php/$1 [QSA,PT,L]
</IfModule>

 

 

第一步:public目录下 build.php文件添加配置

 

[php] view plain copy
 
  1. <?php  
  2. // +----------------------------------------------------------------------  
  3. // | ThinkPHP [ WE CAN DO IT JUST THINK ]  
  4. // +----------------------------------------------------------------------  
  5. // | Copyright (c) 2006~2016 http://thinkphp.cn All rights reserved.  
  6. // +----------------------------------------------------------------------  
  7. // | Licensed ( http://www.apache.org/licenses/LICENSE-2.0 )  
  8. // +----------------------------------------------------------------------  
  9. // | Author: liu21st <liu21st@gmail.com>  
  10. // +----------------------------------------------------------------------  
  11.   
  12. return [  
  13.     // 生成应用公共文件  
  14.     '__file__' => ['common.php', 'config.php', 'database.php'],  
  15.   
  16.     // 定义demo模块的自动生成 (按照实际定义的文件名生成)  
  17.     'admin'     => [  
  18.         '__file__'   => ['common.php'],  
  19.         '__dir__'    => ['behavior', 'controller', 'model', 'view'],  
  20.         'controller' => ['Index', 'User','Config'],  
  21.         'model'      => ['Models', 'ModelsField','Config'],  
  22.         'view'       => ['index/index','config/index'],  
  23.     ],  
  24.     // 其他更多的模块定义  
  25. ];  


index.pxp修改为:

 

 

[php] view plain copy
 
      1. <?php  
      2. // +----------------------------------------------------------------------  
      3. // | ThinkPHP [ WE CAN DO IT JUST THINK ]  
      4. // +----------------------------------------------------------------------  
      5. // | Copyright (c) 2006-2016 http://thinkphp.cn All rights reserved.  
      6. // +----------------------------------------------------------------------  
      7. // | Licensed ( http://www.apache.org/licenses/LICENSE-2.0 )  
      8. // +----------------------------------------------------------------------  
      9. // | Author: liu21st <liu21st@gmail.com>  
      10. // +----------------------------------------------------------------------  
      11.   
      12. // [ 应用入口文件 ]  
      13.   
      14. // 定义应用目录  
      15. define('APP_PATH', __DIR__ . '/../application/');  
      16. // 加载框架引导文件  
      17. require __DIR__ . '/../thinkphp/start.php';  
      18. //读取自动生成定义文件  
      19. $build = include 'build.php';  
      20. //运行自动生成  
      21. \think\Build::run($build);  

 

4.在网页上面搜索域名即可

 
 
posted @ 2018-03-13 11:46  半夏小疯子  阅读(441)  评论(0编辑  收藏  举报