CakePHP 環境構築してみた

公開日: : PHP , , , ,

こんにちはJです。
サッカー日本代表負けてしまいましたね(>o<)
ドログバ、マジやべ〜っす。
次の試合は、ギリシャ!! 頑張れニッポン!!

ところで最近、CakePHPを初めて触ってみました。

2.X ブログチュートリアル
このサイトのチュートリアルをやってみようと
環境構築から始めたのですが、
ちょっとハマったりもしたので
環境構築の手順をメモしておきたいと思います。

今回は、練習ですのでXAMPPでPHP開発環境を構築してます。
(その導入手順はここでは省略してます)

1.Cakeのダウンロード

まずは、Cakeをダウンロードして「/xamppfiles/htdocs」に配置します。
ディレクトリ名を「cake」に変更しましょう。
(変更しなくても特に問題は無いです。)

2.tmpのパーミッション変更

app/tmpディレクトリのパーミッションを変更します。
手っ取り早くchmodコマンドで権限を変更しました。

chmod -R 777 app/tmp

※注意
パーミッション変更しないままCakeのwelcomeページをひらくと以下の様なエラーがでます。

Warning: _cake_core_ cache was unable to write ‘cake_dev_ja’ to File cache in /Applications/XAMPP/xamppfiles/htdocs/cakephp-2.5.1/lib/Cake/Cache/Cache.php on line 323
Warning: /Applications/XAMPP/xamppfiles/htdocs/cakephp-2.5.1/app/tmp/cache/persistent/ is not writable in /Applications/XAMPP/xamppfiles/htdocs/cakephp-2.5.1/lib/Cake/Cache/Engine/FileEngine.php on line 384
Fatal error: Uncaught exception ‘CacheException’ with message ‘Cache engine _cake_core_ is not properly configured.’ in /Applications/XAMPP/xamppfiles/htdocs/cakephp-2.5.1/lib/Cake/Cache/Cache.php:181 Stack trace: #0 /Applications/XAMPP/xamppfiles/htdocs/cakephp-2.5.1/lib/Cake/Cache/Cache.php(151): Cache::_buildEngine(‘_cake_core_’) #1 /Applications/XAMPP/xamppfiles/htdocs/cakephp-2.5.1/app/Config/core.php(375): Cache::config(‘_cake_core_’, Array) #2 /Applications/XAMPP/xamppfiles/htdocs/cakephp-2.5.1/lib/Cake/Core/Configure.php(72): include(‘/Applications/X…’) #3 /Applications/XAMPP/xamppfiles/htdocs/cakephp-2.5.1/lib/Cake/bootstrap.php(175): Configure::bootstrap(true) #4 /Applications/XAMPP/xamppfiles/htdocs/cakephp-2.5.1/app/webroot/index.php(90): include(‘/Applications/X…’) #5 {main} thrown in /Applications/XAMPP/xamppfiles/htdocs/cakephp-2.5.1/lib/Cake/Cache/Cache.php on line 181

3.データーベース設定

① /app/Config/database.php.defaultファイルをコピーし、
 database.phpにリネームします。
② ファイル内を変更します。
 login,password,database等を各自の設定に合わせて変更しましょう。

 public $default = array(
   ’datasource’ => ‘Database/Mysql’,
   ’persistent’ => false,
   ’host’ => ‘localhost’,
   ’login’ => ‘root’,
   ’password’ => ‘hogehoge’,
   ’database’ => ‘testDB’,
   ’prefix’ => ”,
   ’encoding’ => ‘utf8′,
 );

4.「’Security.salt’」と「’Security.cipherSeed’」を変更

/app/Config/core.phpを編集します。
① Security.salt の値を変更

Configure::write(‘Security.salt’, ‘SKdeslijfaoufdkjo@hois3342ed’);

デフォルト値から、適当な文字列に変更します。
ハッシュの生成に用いられるそうです。

② Security.cipherSeedの値を変更

Configure::write(‘Security.cipherSeed’, ’198264830182746738219′);

デフォルト値から、適当な半角数字に変更します。
暗号化・復号化のための文字列だそうです。

5.確認

Cakeのwelcomeページ(http://localhost/cake)をブラウザで開いてみましょう。
以下の様なメッセージが表示されていたらCakeの開発環境構築は終了です。
cakewelcomepage

関連記事

no image

PHP+MySQLでむやみにハマった3つのこと。

toshiroです。 ゲームの管理画面を作るために、PHP+MySQLを触り始めました。 今回は

記事を読む

head-bottom-picture

Unityサーバー通信 Zend Frameworkの連携

こんばんは、Jです。 沖縄はもう梅雨です。 ジメジメした日が続き、なんとなく気だるさを感じで

記事を読む

Message

メールアドレスが公開されることはありません。 * が付いている欄は必須項目です


*

次のHTML タグと属性が使えます: <a href="" title=""> <abbr title=""> <acronym title=""> <b> <blockquote cite=""> <cite> <code> <del datetime=""> <em> <i> <q cite=""> <strike> <strong>

PAGE TOP ↑