LoginSignup
24
24

More than 5 years have passed since last update.

CakePHP 3.x系初期設定手順メモ

Posted at
  • Ubuntu 14.04, Apache2, MySQL, (とDebugKitの為にsqlite) の構成です
  • 作業メモなので必要最低限の事しか書いてません

ミドルウェア導入

$ sudo apt-get install apache2 libapache2-mod-php5 mysql-server php5-mysql php5-intl sqlite3 php5-sqlite

2系と比べてphp5-intlが増えてます。
sqlite3php5-sqlite はDebugKitをデフォルトのまま使いたいので追加しています。

Composer導入

$ curl -sS https://getcomposer.org/installer | php
$ sudo mv composer.phar /usr/local/bin/composer

Apache設定変更

AllowOverride を None から All に変更

/etc/apache2/apache2.conf
<Directory /var/www/>
        Options Indexes FollowSymLinks
        AllowOverride All
        Require all granted
</Directory>

mod_rewriteを有効

sudo a2enmod rewrite
sudo service apache2 restart

CakePHPの設置

composer create-project --prefer-dist cakephp/app [name]

ディレクトリ権限、salt、DebugKitの設定は勝手にやってくれてます。

DBとユーザ作成

mysql> CREATE DATABASE cake CHARACTER SET utf8;
mysql> GRANT ALL ON *.* to hoge@localhost identified by 'piyo'; FLUSH PRIVILEGES;

DB設定

下らへんを編集。

config/app.php
    'Datasources' => [
        'default' => [
            'className' => 'Cake\Database\Connection',
            'driver' => 'Cake\Database\Driver\Mysql',
            'persistent' => false,
            'host' => 'localhost',
            /**
             * CakePHP will use the default DB port based on the driver selected
             * MySQL on MAMP uses port 8889, MAMP users will want to uncomment
             * the following line and set the port accordingly
             */
            //'port' => 'nonstandard_port_number',
            'username' => 'hoge',
            'password' => 'piyo',
            'database' => 'cake',
            'encoding' => 'utf8',
            'timezone' => 'UTC',
            'cacheMetadata' => true,

以上、http://localhost/[name] にアクセスし、メッセージがオールグリーンなのを確認して終了。
Qiita:CakePHP 2.x系初期設定手順メモに比べるとかなり手間が省けてますね。

お疲れさまでした。

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