PR

CakePHP 1.2 on さくらインターネット(2)

何をするか

  • さくらインターネットにCakePHP1.2.5を導入する
  • セキュアに使うため、CakePHP本体とwebrootを分離して設置する
  • ValueDomainで取得したドメイン(例:bar.com)を使う
  • ValueDomainのDNSを使う(=既にfoo.bar.comは自分のさくらサーバに向いている)
  • foo.bar.comをCakePHPのwebrootとして使う
  • さくらのアカウントをここでは例としてSakuraAccountとする
  • ここでは例としてCakePHP本体を格納するディレクトリ(フォルダ)をcake125とした
  • (既にfoo.bar.com=/home/SakuraAccount/www/foo.bar.comとなるようにさくら側で設定していること)
  • (既にさくら側でデータベースを作成してあること)

スポンサードリンク

設置手順(1)・・・ファイル転送

  1. CakePHPをダウンロードする
  2. 解凍する
  3. FTP で /home/SakuraAccount/cake125 に /cake, /vendors を転送する
  4. FTP で /home/SakuraAccount/www/foo.bar.com に上記以外(/app, index.php, .htaccess)を転送する

設置手順(2)・・・基本設定

◇/home/SakuraAccount/foo.bar.com/.htaccess を編集

<IfModule mod_rewrite.c>
RewriteEngine on
RewriteBase /
RewriteRule    ^$ app/webroot/    [L]
RewriteRule    (.*) app/webroot/$1 [L]
</IfModule>

◇/home/SakuraAccount/foo.bar.com/app/.htaccess を編集

<IfModule mod_rewrite.c>
RewriteEngine on
RewriteBase    /app
RewriteRule    ^$    webroot/    [L]
RewriteRule    (.*) webroot/$1    [L]
</IfModule>

◇/home/SakuraAccount/foo.bar.com/index.phpを編集

/**
* This only needs to be changed if the cake installed libs are located
* outside of the distributed directory structure.
*/
if (!defined(‘CAKE_CORE_INCLUDE_PATH’)) {
//define (‘CAKE_CORE_INCLUDE_PATH’, FULL PATH TO DIRECTORY WHERE CAKE CORE IS INSTALLED DO NOT ADD A TRAILING DIRECTORY SEPARATOR’;
define(‘CAKE_CORE_INCLUDE_PATH’, DS.’home’.DS.’SakuraAccount’.DS.’cake125′);
}

◇/home/SakuraAccount/foo.bar.com/app/webroot/.htaccessを編集

<IfModule mod_rewrite.c>
RewriteEngine On
RewriteBase /
RewriteCond %{REQUEST_FILENAME} !-d
RewriteCond %{REQUEST_FILENAME} !-f
RewriteRule ^(.*)$ index.php?url=$1 [QSA,L]
</IfModule>

◇/home/SakuraAccount/foo.bar.com/app/webroot/index.phpを編集

/**
* The absolute path to the “cake” directory, WITHOUT a trailing DS.
*
*/
if (!defined(‘CAKE_CORE_INCLUDE_PATH’)) {
define(‘CAKE_CORE_INCLUDE_PATH’, DS.’home’.DS.’SakuraAccount’.DS.’cake125′);
}

◇参考にディレクトリ構成(抜粋):

/home
|— /SakuraAccount
|—- /cake125
|        |— /cake
|        |— /venders
| —-/www
|— foo.bar.com
|— /app
|       | — index.php
|       | — .htaccess
|     /webroot
|       | — index.php
|       | — .htaccess
| — index.php
| — .htaccess

※ここまででfoo.bar.comにアクセスするとCakePHPが動作していることが確認できるはず。
この後、データベースの設定(app/config/database.phpの編集)に入っていく。

参考文献

参考文献(主に複数で使うため)

コメント