Love澤's Room

技術系ネタをまとめていたブログ。現在はカテゴリにこだわらず更新中。

CakePHPの設定(エラー解決編)

新サイトへ移転しました
約3秒後に自動的にリダイレクトします。

「エラー解決編」とか題してますが、ほかに○○編とか出さないと思います笑

本日、CakePHPの勉強を初めまして、環境構築をしていく中ででたエラーに関する情報をこちらのページにまとめていきたいと思います。

エラーがでて、解決したら随時更新予定。

タイムゾーンに関するエラー(2015/02/26 18:32 更新)

  • 問題

CakePHPをWebサーバに入れてサンプルページを表示させた際、以下のエラーメッセージが表示されていた。

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 the timezone 'UTC' for now, but please set date.timezone to select your timezone. in /var/www/html/cakephp/lib/Cake/Cache/CacheEngine.php on line 60


  • 原因

CakePHPの設定というより、PHPでタイムゾーンの設定がなされていないことが原因であった。

  • 解決策

/etc/php.iniの889行目あたりにタイムゾーンの設定箇所があるので、そこを以下のように編集。

[Date]
; Defines the default timezone used by the date functions
; http://php.net/date.timezone
date.timezone = Asia/Tokyo

apacheを再起動するとエラーが消える。

systemctl restart httpd (CentOS 7)
etc/rc.d/init.d/httpd restart (CentOS 6,5)
  • 参考文献

http://www.phpbook.jp/cakephp/install/index1.html

パーミッションに関するエラー(2015/02/26 22:07 更新)

Mac OS X + XAMPP + CakePHPという環境を構築しようとした時に以下の様なエラーが表示された。

  • 問題
Warning: mkdir(): Permission denied in /Applications/XAMPP/xamppfiles/htdocs/cakephp/lib/Cake/Cache/Engine/FileEngine.php on line 380

Warning: _cake_core_ cache was unable to write 'cake_dev_ja' to File cache in /Applications/XAMPP/xamppfiles/htdocs/cakephp/lib/Cake/Cache/Cache.php on line 328

Warning: /Applications/XAMPP/xamppfiles/htdocs/cakephp/app/tmp/cache/persistent/ is not writable in /Applications/XAMPP/xamppfiles/htdocs/cakephp/lib/Cake/Cache/Engine/FileEngine.php on line 385

Fatal error: Uncaught exception 'CacheException' with message 'Cache engine "_cake_core_" is not properly configured. Ensure required extensions are installed, and credentials/permissions are correct' in /Applications/XAMPP/xamppfiles/htdocs/cakephp/lib/Cake/Cache/Cache.php:186 Stack trace: #0 /Applications/XAMPP/xamppfiles/htdocs/cakephp/lib/Cake/Cache/Cache.php(151): Cache::_buildEngine('_cake_core_') #1 /Applications/XAMPP/xamppfiles/htdocs/cakephp/app/Config/core.php(374): Cache::config('_cake_core_', Array) #2 /Applications/XAMPP/xamppfiles/htdocs/cakephp/lib/Cake/Core/Configure.php(72): include('/Applications/X...') #3 /Applications/XAMPP/xamppfiles/htdocs/cakephp/lib/Cake/bootstrap.php(175): Configure::bootstrap(true) #4 /Applications/XAMPP/xamppfiles/htdocs/cakephp/app/webroot/index.php(100): include('/Applications/X...') #5 {main} thrown in /Applications/XAMPP/xamppfiles/htdocs/cakephp/lib/Cake/Cache/Cache.php on line 186

  • 原因

CakePHPの app/etc のパーミッションの設定が777になっていなかった

  • 解決策

app/etc のパーミッションを777にすると解決する。

sudo chmod -R 777 app/etc
  • 参考文献

Cakephp2.3 インストール時のエラー - Qiita