LoginSignup
0
0

More than 5 years have passed since last update.

CakePHP3環境構築メモ(PHPとMySQLのインストールまで)

Posted at

最近CakePHP3の勉強を始めたのですが、最初の環境構築の段階で躓いたのでメモしておきます。

環境

CentOS7 (Vagrant)

$ cat /etc/redhat-release
CentOS Linux release 7.5.1804 (Core)

導入するバージョン

  • PHP 5.6.36
  • MySQL 5.6.40

ドットインストールを用いて学習したため、その環境に合わせています。

PHPのインストール

yumでそのまま入れるとPHP5.4が入ります。
CakePHP3のシステム要件は5.6以上なため、EPELとRemiリポジトリを追加しインストールします。

# yum install epel-release
# rpm -Uvh http://rpms.famillecollet.com/enterprise/remi-release-7.rpm
# yum install --enablerepo=remi,remi-php56 php php-devel php-mbstring php-pdo php-gd php-xml php-mcrypt php-mysqlnd

タイムゾーンの設定を行います。

# vi /etc/php.ini
...略...
[Date]
; Defines the default timezone used by the date functions
; http://www.php.net/manual/en/datetime.configuration.php#ini.date.timezone
;date.timezone =
date.timezone = Asia/Tokyo # 追記
...略....
$ php -v
PHP 5.6.36 (cli) (built: Apr 25 2018 10:02:39)
Copyright (c) 1997-2016 The PHP Group
Zend Engine v2.6.0, Copyright (c) 1998-2016 Zend Technologies

続いてintl拡張をインストールします。

# yum install --enablerepo=remi --enablerepo=remi-php56 -y php-intl

init.iniファイルを作成し以下のように入力します。

# vi /etc/php.d/intl.ini
extension=/opt/remi/php56/root/usr/lib64/php/modules/intl.so

正常に導入された場合、以下のよう表示されます。

$ php -i | grep intl
/etc/php-5.6.d/20-intl.ini,
/etc/php-5.6.d/intl.ini,
intl
intl.default_locale => no value => no value
intl.error_level => 0 => 0
intl.use_exceptions => 0 => 0

MySQLのインストール

CentOS7のデフォルトではMariaDBがインストールされます。

デフォルトのMariaDBを削除します。

# yum remove mariadb-libs
# rm -rf /var/lib/mysql/

MySQL公式のリポジトリを追加します。
公式サイトのLinux 7用のダウンロードURLをコピーします。
MySQL :: Download MySQL Yum Repository

# yum localinstall [コピーしたURL]

以下のコマンドで追加されたMySQLのリポジトリ一覧を表示します。

$ yum repolist all | grep mysql
mysql-cluster-7.5-community/x86_64 MySQL Cluster 7.5 Community      無効
mysql-cluster-7.5-community-source MySQL Cluster 7.5 Community - So 無効
mysql-cluster-7.6-community/x86_64 MySQL Cluster 7.6 Community      無効
mysql-cluster-7.6-community-source MySQL Cluster 7.6 Community - So 無効
!mysql-connectors-community/x86_64 MySQL Connectors Community       有効:     51
...略..

私の場合デフォルトではmysql80が有効になっていたため、mysql80を無効にし、今回欲しいmysql56を有効にします。

# yum install yum-utils
$ yum-config-manager --disable mysql80-community
$ yum-config-manager --enable mysql56-community

この状態で下のコマンドを実行すればMySQL5.6がインストールされます。

# yum install mysql-community-server
$ mysqld --version
mysqld  Ver 5.6.40 for Linux on x86_64 (MySQL Community Server (GPL))

以上で、CakePHP3を始めるための環境が構築出来ました。

参考

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