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
php

 

 

[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路徑
一、若是沒有開啓 URL_REWRITE,則你須要找到 Apache 中的 httpd.conf 這個配置文件,找到下面這行:


#LoadModule rewrite_module modules/mod_rewrite.so


把前面的警號去掉,而後繼續找到下面這句:


二、AllowOverride None


將全部找到的以上語句都改成:AllowOverride All


以上修改完畢而後重啓 Apache 服務器便可。


三、在應用的根目錄下面新建一個 .htaccess 文件。在文件裏面加入以下代碼:
<IfModule mod_rewrite.c>
RewriteEngine on
RewriteCond %{REQUEST_FILENAME} !-d
RewriteCond %{REQUEST_FILENAME} !-f
RewriteRule ^(.*)$ index.php/$1 [QSA,PT,L]
</IfModule>
html

 

 

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

 

[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修改成:thinkphp

 

 

[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.在網頁上面搜索域名便可apache

相關文章
相關標籤/搜索