ぺんぎんノート

momoiro_tjのノート (旧:システムオペレータの週末)

cakePHPインストールでハマった話。(intl.so)

Laravelいろいろさわってましたが、とりあえずいろいろPHPフレームワーク触ってみることにしました。

というわけで、cakePHPやってみることに。

composerはインストール済みとします。

ドキュメントに従いインストール

cakePHPクイックスタートガイドをもとに進めていきます。

webサーバのルートとなるディレクトリに移動。
ビルトインの簡易サーバもつかえるので、適当なディレクトリでいいと思います。

composerのcreate-projectコマンドでcakePHPプロジェクトを導入します。

$ composer create-project --prefer-dist cakephp/app test

  Problem 1
    - cakephp/cakephp 3.1.7 requires ext-intl * -> the requested PHP extension intl is missing from your system.
    - cakephp/cakephp 3.1.6 requires ext-intl * -> the requested PHP extension intl is missing from your system.
    - cakephp/cakephp 3.1.5 requires ext-intl * -> the requested PHP extension intl is missing from your system.
    - cakephp/cakephp 3.1.4 requires ext-intl * -> the requested PHP extension intl is missing from your system.
    - cakephp/cakephp 3.1.3 requires ext-intl * -> the requested PHP extension intl is missing from your system.
    - cakephp/cakephp 3.1.2 requires ext-intl * -> the requested PHP extension intl is missing from your system.
    - cakephp/cakephp 3.1.1 requires ext-intl * -> the requested PHP extension intl is missing from your system.
    - cakephp/cakephp 3.1.0 requires ext-intl * -> the requested PHP extension intl is missing from your system.
    - Installation request for cakephp/cakephp ~3.1 -> satisfiable by cakephp/cakephp[3.1.0, 3.1.1, 3.1.2, 3.1.3, 3.1.4, 3.1.5, 3.1.6, 3.1.7].

なんかエラー出てるみたい。

どうも、intlというPHP拡張が無いようです。

intlの導入

調べてみると、peclつかったりしないといけなそう。

CakePHP3.0をインストールしてみる(自分用めもめも - Qiita

うーん。

とりあえず、yumコマンドでintlが無いか探してみる。

$ yum list | grep intl

php-intl.x86_64                           5.6.16-1.fc23                updates

あった!!!!もしかして、これ入れればいけるんじゃ・・・?

// php-intlをインストール
$ sudo yum install php-intl

//phpコマンドで確認
$ php -i | grep intl

/etc/php.d/20-intl.ini,
intl
intl.default_locale => no value => no value
intl.error_level => 0 => 0
intl.use_exceptions => 0 => 0

いけた!!!

最後に、/etc/php.iniextension=intl.soを追加。

もう一度インストール!

一度インストールしたディレクトリをすべて削除して、もう一度composerでcakePHPをインストール。

$ composer create-project --prefer-dist cakephp/app test

Writing lock file
Generating autoload files

Set Folder Permissions ? (Default to Y) [Y,n]? Y

途中、ディレクトリのパーミッションを変更するか確認されるので、「Y」で応答。

1回目のブラウザ確認

ブラウザから、http://localhostにアクセスして確認。

あれ、見れない。そもそもwebサーバが落ちてる。しかも上がらない。。。

しらべてみると、ダミーのindex.htmlが必要とのこと。内容は空か、<html></html>でいいみたい。

ドキュメントルートにindex.htmlを追加。もう一度、apacheを起動。お、あがってきた。

2回目のブラウザ確認

再度、http://localhostへアクセス。

それっぽい画面が出たけど、、、、パーミッションエラー。

このパターン最近見たぞ、と思ってSELINUXのコンテキストを変更。

chcon -R -t httpd_sys_rw_content_t .

(詳しくは前の記事を参照。)

momoiro-tj.hateblo.jp

最後のブラウザ確認

3度目の正直、http://localhostへアクセス。

いけたー!ケーキのイラストが表示された!

webアプリはセキュリティとかパーミッションでいっつもやられるなー。

というわけで、今日からcakePHPで遊んでみます。