LoginSignup
0
1

More than 5 years have passed since last update.

[CakePHP2]インストールの覚え書きです。

Last updated at Posted at 2019-04-28

いきなり仕事でCakePHPを使うことになりました(しかも、cakePHP2...)。

早速インストール。
CakePHP2をGitからダウンロードして、サーバーに置いたらエラーが出たので対処方法をまとめておきます。

+パーミッションのエラー

  • エラー内容
Your tmp directory is NOT writable.

/app/tmp 以下のパーミッションに書き込み権限(0777)を与えましょう。

+timezoneのエラー

  • エラー内容
Warning: strtotime(): It is not safe to rely on the system's timezone settings. You are *required* to use the date.timezone setting or the date_default_timezone_set() function. In case you used any of those methods and you are still getting this warning, you most likely misspelled the timezone identifier. We selected 'Asia/Tokyo' for 'JST/9.0/no DST' instead in /lib/Cake/Cache/CacheEngine.php on line 60

CacheEngine.php に「date_default_timezone_set('Asia/Tokyo');」を追加しましょう。

/lib/Cake/Cache/CacheEngine.phpの59-61行目
if (!is_numeric($this->settings['duration'])) {
        date_default_timezone_set('Asia/Tokyo');
        $this->settings['duration'] = strtotime($this->settings['duration']) - time();
}

.htaccessに「php_value date.timezone Asia/Tokyo」でもいけました。

/.htaccess
php_value date.timezone Asia/Tokyo

+Security.saltのエラー

  • エラー内容
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 842]

core.php の security.salt の値を変更する。

/app/Config/core.php235行目あたり
/**
 * A random string used in security hashing methods.
 */
    Configure::write('Security.salt', 'DYhG93b0qyJfIxfs2guVoUubWwvniR2G0FgaC9mi');

/**
 * A random numeric string (digits only) used to encrypt/decrypt strings.
 */
    Configure::write('Security.cipherSeed', '76859309657453542496749683645');
}
Configure::write('Security.salt', 'DYhG93b0qyJfIxfs2guVoUubWwvniR2G0FgaC9mi');

こちらのサイトでランダム文字列を取得できるのでそのまま貼り付けましょう。

+Databaseのエラー1

  • エラー内容
Warning (2): include_once(/app/Config/database.php): failed to open stream: No such file or directory [CORE/Cake/Model/ConnectionManager.php, line 67]

/app/Config内にあるdatabase.php.defaultをコピーしてdatabase.phpを作ってアップロードしましょう。

+Databaseのエラー2

  • エラー内容
CakePHP is NOT able to connect to the database.
Database connection "Mysql" is missing, or could not be created.
SQLSTATE[28000] [1045] Access denied for user 'user'@'localhost' (using password: YES)

データベースを用意して/app/Config/database.phpに設定値を入力しましょう。

/app/Config/database.php69行目あたり
    public $default = array(
        'datasource' => 'Database/Mysql',
        'persistent' => false,
        'host' => 'localhost',
        'login' => 'user',
        'password' => 'password',
        'database' => 'database_name',
        'prefix' => '',
        //'encoding' => 'utf8',
    );

+DebugKitのエラー

  • エラー内容
DebugKit is not installed. It will help you inspect and debug different aspects of your application.
You can install it from GitHub

DebugKitをGitからダウンロード。
解凍したフォルダを「Debugkit」にリネームして/app/Pluginにアップしましょう。

/app/Config/bootstrap.phpにプラグイン設定を入力します。
これでプラグインを読み込んでくれます。

/app/Config/bootstrap.phpの最終行に追加
CakePlugin::load('DebugKit');

これで一通りのエラーは解決だと思います。
いまさらのcakephp2だから気を付けていきましょう。

0
1
0

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
0
1