LoginSignup
7
6

More than 5 years have passed since last update.

CentOS7でCakePHP2.5を動かす

Last updated at Posted at 2014-10-21

Apache設定

CakePHPが.htaccessでmod_rewriteを使うので以下修正。

/etc/httpd/conf/httpd.conf
  <Directory "/var/www/html">
  ...
- AllowOverride None
+ AllowOverride All
  ...
  </Directory>
httpd -S
systemctl restart httpd

CakePHPダウンロード

cd /var/www/html
wget https://codeload.github.com/cakephp/cakephp/zip/2.5.5
unzip 2.5.5
cd cakephp-2.5.5
git clone https://github.com/cakephp/debug_kit.git app/Plugin/DebugKit
cp app/Config/database.php{.default,}
sudo chown -R apache:apache .

Security値変更

app/Config/core.php
- Configure::write('Security.salt', 'DYhG93b0qyJfIxfs2guVoUubWwvniR2G0FgaC9mi');
- Configure::write('Security.cipherSeed', '76859309657453542496749683645');
+ Configure::write('Security.salt', 'DYHG93B0QYJFIXFS2GUVOUUBWWVNIR2G0FGAC9MI');
+ Configure::write('Security.cipherSeed', '74968364576859309657453542496');
  • 書き換える。

Database接続設定

app/Config/database.php
class DATABASE_CONFIG {

        public $default = array(
                'datasource' => 'Database/Mysql',
                'persistent' => false,
                'host' => 'localhost',
                'login' => 'root',
                'password' => '',
                'database' => 'test',
                'prefix' => '',
                'encoding' => 'utf8',
        );
}

DebugToolbarを表示させたい場合

app/Config/bootstrap.php末尾に追加
+ CakePlugin::load('DebugKit');
app/Controller/AppController.php
  class AppController extends Controller {
+   public $components = array('DebugKit.Toolbar');
  }

E_STRICTが表示されるのを抑止

  • php5.4からerror_reportingがE_STRICTも出すようになった。
  • CakePHPはフレームワーク内でerror_reportingを設定しているため、php.iniではなく以下で設定する。
app/Config/core.php
  Configure::write('Error', array(
      'handler' => 'ErrorHandler::handleError',
-     'level' => E_ALL & ~E_DEPRECATED,
+     'level' => E_ALL & ~E_DEPRECATED & ~E_STRICT,
      'trace' => true
  ));

参考: CakePHP2.xとPHP5.4でStrict Errorが出た場合の対処法

7
6
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
7
6