global menu
search this site
sponsored links

sponsored links
store
category archive
monthly archive
powered by

エントリーアーカイブ

CentOS 5にCakePHP 1.2系のインストール

PHP

2008/07/01 17:33

インストール手順

  1. CakePHPのダウンロード
    公式サイトの右上のDownloadから最新版を取得する。(現時点ではRelease Candidates)
  2. CakePHPの設置
    cake_x.x.xx.xxxx.tar.gzを解凍する。
    tar zxvf cake_x.x.xx.xxxx.tar.gz
    
    解凍されたファイルを設置する。(設置場所はセキュリティを考慮する為に後々考える。今は開発環境なので解凍されたフォルダをDocumentRootとする。)
  3. httpd.confの編集
    .htaccessを使用可能にする為、CakePHPを設置した公開ディレクトリのディレクティブを以下の様に設定。
    vi /etc/httpd/conf/httpd.conf
    
    今回は、ドキュメントルートに設置してあるのでルートのディレクティブを変更する。変更箇所は以下の部分。
    </Directory (DocumentRoot)>
        AllowOverride All
        Options Indexes FollowSymLinks
        Order allow,deny
        Allow from all
    </Directory>
    
    変更後はApacheの再起動。
    /sbin/service httpd restart
  4. テンポラリフォルダの所有権変更
    テンポラリフォルダに書き込み権限が必要なので所有権をwebサーバの実行ユーザーに変更。
    chown -R apache (DocumentRoot)/app/tmp
  5. RewriteBaseの設定
    3つある.htaccessをそれぞれ編集する。まずは1つ目。
    vi (DocumentRoot)/.htaccess
    RewriteEngine onの直下に以下を追加。
    RewriteBase /
    UserDirで公開時には、
    RewriteBase /~(UserName)
    2つ目。
    vi (DocumentRoot)/app/.htaccess
    RewriteEngine onの直下に以下を追加。
    RewriteBase /app
    UserDirで公開時には、
    RewriteBase /~(UserName)/app
    3つ目。
    vi (DocumentRoot)/app/webroot/.htaccess
    RewriteEngine onの直下に以下を追加。
    RewriteBase /app/webroot
    UserDirで公開時には、
    RewriteBase /~(UserName)/app/webroot
  6. データベース接続の設定
    cp (DocumentRoot)/app/config/database.php.default (DocumentRoot)/app/config/database.php
    vi (DocumentRoot)/app/config/database.php
    
    database.phpの最下部に、
    var $default = array(
            'driver' => 'mysql',
            'persistent' => false,
            'host' => 'localhost',
            'login' => 'user',
            'password' => 'password',
            'database' => 'database_name',
            'prefix' => '',
    );
    
    var $test = array(
            'driver' => 'mysql',
            'persistent' => false,
            'host' => 'localhost',
            'login' => 'user',
            'password' => 'password',
            'database' => 'test_database_name',
            'prefix' => '',
    );
    
    という部分があるので、以下の様に書き換える。文字エンコーディングの指定を忘れない様に。
    var $default = array(
            'driver' => 'mysql',
            'persistent' => false,
            'host' => 'localhost',
            'login' => '(任意のユーザ名)',
            'password' => '(任意のパスワード)',
            'database' => '(任意のデータベース名)',
            'prefix' => '',
            'encoding' => 'utf8'
    );
    
  7. ハッシュ作成に使用される文字列の変更
    設定ファイルを開き、
    vi (DocumentRoot)/app/config/core.php
    デフォルトで記述されている文字列を任意の文字列に変更する。
    Configure::write('Security.salt', '(任意の文字列)');

関連記事