CakePHPの導入方法について、記述します。
事前準備として、サーバ環境はVagrantで構築して、http://dev.cakephp-test.com/というURLを与えています。
これをhttp://dev.cakephp-test.com/tutorial/として、アクセスしてCakPHPを使用していきます。
CakePHPをダウンロードする
公式サイトからCakePHPをダウンロードして、作業ディレクトリにファイル一式コピーします。 今回は、tutorialディレクトリを作成して、その中にコピーしました。
ターミナルにて、作業ディレクトリに移動して下記コマンドを入力します。 tmpディレクトリのアクセス権を変更します。
1 2 | |
セキュリティ設定を変更する
この時点で、http://dev.cakephp-test.com/tutorial/にアクセスすると、色々とメッセージが出ていると思います。
例えば…
Notice (1024): Please change the value of ‘Security.salt’ in APP/Config/core.php to a salt value specific to your application. [CORE/Cake/Utility/Debugger.php, line 846] Notice (1024): Please change the value of ‘Security.cipherSeed’ in APP/Config/core.php to a numeric (digits only) seed value specific to your application. [CORE/Cake/Utility/Debugger.php, line 850]
上記メッセージにあるようにapp/config/core.phpを開いて、Security.salt,Security.cipherSeedの適当な好きな文字列に変更しましょう。
DBの設定を行う
app/config/database.php.defaultファイルをコピーして、database.phpを作成します。
1
| |
下記部分を変更します。
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 | |
次にDBを作成します。
1 2 3 4 5 6 7 8 9 | |
Debug_kitをダウンロードする
下記コマンドを入力します。
1 2 | |
app/Config/bootstrap.phpにCakePlugin::load('DebugKit');という記述を追加します。
また、app/Controller/AppController.phpに下記内容を追加します。
1 2 3 | |
以上でCakePHPを使用する準備が整いました。 あとは、[ブログチュートリアル]な(http://book.cakephp.org/2.0/ja/getting-started.html)どを参考に勉強していくのがよいですね!
なお、この時点でhttp://dev.cakephp-test.com/tutorial/にアクセスしたときに下記のようなメッセージが表示されている場合は、以下のことを行ってみてください。
メッセージ:URL rewriting is not properly configured on your server. 1) Help me configure it 2) I don’t / can’t use URL rewriting
httpd.confを編集します。
1 2 3 4 5 6 7 8 9 | |
次に、作業ディレクトリ(今回の場合、tutorial)に.htaccessファイルを作成します。
そして、下記内容を記述します。
1 2 3 4 5 | |