zoukankan      html  css  js  c++  java
  • CakePHP 1.2 簡易安裝與設定

    首先到CakePHP官網 ,下載目前1.2 beta 版並解壓縮。
    安裝 Apache + PHP + MySQL,安裝Apache時,建議安裝mod_rewrite。


    I. 設定 Apache

    在安裝Apache時,建議安裝mod_rewrite,讓你的網站網址更容易SEO接受與分析。

    新增一組 Directory 設定,目錄是你的 your_cakephp1.2/app/webroot。設定如下:

    <Directory "your_cakephp1.2/app/webroot/">
    Options FollowSymLinks
    AllowOverride All
    Order allow,deny
    Allow from all
    </Directory>

    請設定 AllowOverride All,如此mod_rewrite會參照cakephp目錄中的.htaccess來做轉址。

    最後將你的 DocumentRoot 指到your_cakephp1.2/app/webroot。

    如果沒有意外的話,你就可以看到cakephp的說明首頁。

    最後測試你的mod_rewrite有沒有成功,如果 http://your_domain/pages/display 和 http://your_domain/ 是同一頁,

    那就ok了!


    II. 設定 Cakephp

    還沒開始設定 Cakephp之前,你的Cakephp的說明首頁會有許多警告訊息。

    1. DB 設定

    在 your_cakephp1.2/app/config/ 有 database.php.default 請copy 或 rename 成 database.php,依照你的Database帳號/密碼設定,加到這個文件檔中。Cakephp預設是使用MySQL,所以設定上應該沒什麼太大的問題。預設有兩組設定,一個是default, 一個是test,如果沒有特別的需求,就把這兩組都設成一樣。


    2. Core 設定

    在 your_cakephp1.2/app/config 的core.php,有很多cakephp的相關設定,當然你也可以把自己網站上的共用設定寫在這邊,寫法如同cakephp,使用Configure::write;這與cakephp1.1版使用define方式不同,屆時要讀取設定時,請用Configure::read。


    core.php中,最常用到的設定有:

    (1). Configure::write('debug', 2); 這是設定你的網站目前是在開放給外人使用的模式,還是開發模式;簡單來說,當你要開放你的網站時,請把debug設定 0。 通常開發時,是設定成 2;在開發的過程中,你會看到cakephp是如何執行SQL命令。如果你要看更詳細的資訊,包括整個程式的所有變數值,那就設定成 3 。


    (2). Configure::write('Cache.check', true); 這是使用網頁Cache機制的開關,預設是註解的,通常網站都會需要做cache,建議在開發時,先關閉這項功能,等到開發後期調整cache時,再打開使用。


    (3). Configure::write('Session.save', 'php'); Session的處理方式,預設是使用php的方式來處理Session。Cakephp也有內建模組,使用Database來處理Session。如果你的網站主機有很多台機器時,那也許可以改用database的方式;另外建議把放Session的table設定在Memory(Heap)的模式,可以加快處理速度。


    (4). Configure::write('Security.salt', 'DYhG93b0qyJfIxfs2guVoUubWwvniR2G0FgaC9mi'); 在你的說明首頁上,一開始也會看到這則警告,請把這個值改成你自己的亂數字串即可。這個設定主要是使用在Cookie;Cakephp的Cookie模組有支援cipher加密功能,屆時Cookie會依照這個值來做加密。


    (5). Cache::config('default', array('engine' => 'File')); Cache 設定,預設是用檔案的方式來做cache;Cakephp也內建模組,可以使用database, xcache, memcache, apc 等常見的方法來做cache。如果你是使用database也建議你把cache的table設定在Memory(Heap)的模式,可以加快處理速度。


    III. 開始寫程式

    如果都設定完成,基本上就可以開始寫程式了!


    相關網站:

    CakePHP官網:http://www.cakephp.org

    1.1手冊: http://manual.cakephp.org/

    1.2手冊: http://book.cakephp.org

    API說明:http://api.cakephp.org/

    CakePHP程式碼討論與分享: http://bakery.cakephp.org/

  • 相关阅读:
    POJ3320 Jessica's Reading Problem
    POJ3320 Jessica's Reading Problem
    CodeForces 813B The Golden Age
    CodeForces 813B The Golden Age
    An impassioned circulation of affection CodeForces
    An impassioned circulation of affection CodeForces
    Codeforces Round #444 (Div. 2) B. Cubes for Masha
    2013=7=21 进制转换
    2013=7=15
    2013=7=14
  • 原文地址:https://www.cnblogs.com/derrck/p/1456590.html
Copyright © 2011-2022 走看看