CodeIgniter安裝

1.codeigniter 下載 http://codeigniter.com/


2.檔案裡面有
codeigniter_版本號碼
 └┬application-你撰寫存放的地方
├system-系統核心的地方(最好不要修改)
├user_guide-說明書
├index.php-設定基本參數
└license.txt-權利書


3.將application、system、index.php複製到網頁目錄

4.設定rewrite
linux:
a2enmod rewrite
windows:
修改apache的httpd.conf將
#LoadModule rewrite_module modules/mod_rewrite.so
前面的#去掉

設定完成都要重新啟動apache


5.建立.htaccess
linux:
直接在跟index.php同層打 vi .htaccess
輸入下面code存檔即可
windows:
因為windows不支援沒檔名的檔案創立
所以在application或是在system裡面都有此檔案
複製到跟index.php同層
用筆記本開起編輯

將.htaccess
內容編輯為
<IfModule mod_rewrite.c>
    RewriteEngine On
    RewriteBase /

    #Removes access to the system folder by users.
    #Additionally this will allow you to create a System.php controller,
    #previously this would not have been possible.
    #'system' can be replaced if you have renamed your system folder.
    RewriteCond %{REQUEST_URI} ^system.*
    RewriteRule ^(.*)$ /index.php?/$1 [L]

    #When your application folder isn't in the system folder
    #This snippet prevents user access to the application folder
    #Submitted by: Fabdrol
    #Rename 'application' to your applications folder name.
    RewriteCond %{REQUEST_URI} ^application.*
    RewriteRule ^(.*)$ /index.php?/$1 [L]

    #Checks to see if the user is attempting to access a valid file,
    #such as an image or css document, if this isn't true it sends the
    #request to index.php
    RewriteCond %{REQUEST_FILENAME} !-f
    RewriteCond %{REQUEST_FILENAME} !-d
    RewriteRule ^(.*)$ index.php?/$1 [L]
</IfModule>

<IfModule !mod_rewrite.c>
    # If we don't have mod_rewrite installed, all 404's
    # can be sent to index.php, and everything works as normal.
    # Submitted by: ElliotHaughin

    ErrorDocument 404 /index.php
</IfModule>

RewriteBase / 要設定為你放在跟目錄哪裡
例如:你開啟網頁的網址為http://localhost/index.php
那就是RewriteBase /
要是網址為http://localhost/CI/index.php
就要改成RewriteBase /CI/

RewriteCond %{REQUEST_URI} ^system.*
RewriteCond %{REQUEST_URI} ^application.*
是用來保護程式的假設你資料夾名稱有改
上面的名稱也要改
這樣才會保護到你的程式

RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
是用來判斷是否有資料夾或是資料
例如:你在網址打http://localhost/css/
你下面沒有css的資料夾他就會導向其他地方
假設下面有css的資料夾他就不會導向

RewriteRule ^(.*)$ index.php?/$1 [L]
將RewriteBase後面的所有東西
都導向index.php?
例如: http://localhost/CI/welcome
在系統裡面就會變成 http://localhost/CI/index.php?/welcome
外面仍然是http://localhost/CI/welcome


6.設定config.php
放在application→config
將config.php裡面修改
$config['base_url']    = 'http://localhost/';
改成你自己的domain name
有放在目錄下要加上去
$config['index_page'] = 'index.php';
將index.php去除

7.設定database.php
放在application→config
將config.php裡面修改
$db['default']['hostname'] = 'localhost';//databaase的位置

$db['default']['username'] = 'root';//帳號
$db['default']['password'] = 'root123';//密碼
$db['default']['database'] = '';//資料庫名稱
$db['default']['dbdriver'] = 'mysql';//資料庫類型


8.開啟網頁
首先先輸入正常的跟目錄網址
要是看到跟下面一樣的圖
就是成功一半了
接下來就在和後面加上welcome也是跟下面一樣代表就是安裝成功了

0 意見:

張貼留言