ukoasis blog


October 14, 2013

自分のPHP脳は5.3くらいで止まっていて、5.4、5.5で入った機能は ( ´_ゝ`)フーン位しか知らずちょっと見てみようと思う
まずはジェネレータがおもろそうだなと思ってのでphp5.5を導入! optionの見方とか直ぐに忘れるので備忘録的に記述します


  • homebrewはインストール済み
  • tapでhomebrew-phpは追加済み


  • コンパイル時のオプションを確認
brew options php55
	Build 32-bit only.
	Build against apxs in Homebrew prefix
	Enable building of the CGI executable (implies --without-apache)
	Compile with debugging symbols
	Enable building of the fpm SAPI executable (implies --without-apache)
	Build with gmp support
	Include LibXSLT support via Homebrew
	Include OpenSSL support via Homebrew
	Include IMAP extension
	Include internationalization support
	Include (old-style) libmysql support
	Include MSSQL-DB support
	Include PostgreSQL support
	Build with thread safety
	Include Tidy support
	Build without shared Apache 2.0 Handler module
	Build without bz2 support
	Remove MySQL/MariaDB support
	Build without Process Control support
	Build without PEAR


  • nginx使いたい
  • 取得したHTMLを加工したい
  • Symfony2使うかも・・

brew install php55 --with-fpm --with-intl --with-tidy

上記コマンド実施でしばしコンパイル待ち・・ つらつらWarningが出ましたが完了時にまとめて表示されるのでそれを確認

☆☆☆☆ PEAR ☆☆☆☆

If pear complains about permissions, 'Fix' the default PEAR permissions and config:
    chmod -R ug+w /usr/local/Cellar/php55/5.5.4/lib/php
    pear config-set php_ini /usr/local/etc/php/5.5/php.ini

✩✩✩✩ Extensions ✩✩✩✩

If you are having issues with custom extension compiling, ensure that
you are using the brew version, by placing /usr/local/bin before /usr/sbin in your PATH:


PHP55 Extensions will always be compiled against this PHP. Please install them
using --without-homebrew-php to enable compiling against system PHP.

✩✩✩✩✩ INTL Support ✩✩✩✩✩

icu4c is broken as of mxcl/homebrew#03ed757c, so you will need to install intl as
a separate extension:

    brew install php55-intl

✩✩✩✩ FPM ✩✩✩✩

To launch php-fpm on startup:
    * If this is your first install:
        mkdir -p ~/Library/LaunchAgents
        cp /usr/local/Cellar/php55/5.5.4/homebrew-php.josegonzalez.php55.plist ~/Library/LaunchAgents/
        launchctl load -w ~/Library/LaunchAgents/homebrew-php.josegonzalez.php55.plist

    * If this is an upgrade and you already have the homebrew-php.josegonzalez.php55.plist loaded:
        launchctl unload -w ~/Library/LaunchAgents/homebrew-php.josegonzalez.php55.plist
        cp /usr/local/Cellar/php55/5.5.4/homebrew-php.josegonzalez.php55.plist ~/Library/LaunchAgents/
        launchctl load -w ~/Library/LaunchAgents/homebrew-php.josegonzalez.php55.plist

The control script is located at /usr/local/Cellar/php55/5.5.4/sbin/php55-fpm

Mountain Lion comes with php-fpm pre-installed, to ensure you are using the brew version you need to make sure /usr/local/sbin is before /usr/sbin in your PATH:


You may also need to edit the plist to use the correct "UserName".

Please note that the plist was called 'org.php-fpm.plist' in old versions
of this formula.

To have launchd start php55 at login:
    ln -sfv /usr/local/opt/php55/*.plist ~/Library/LaunchAgents
Then to load php55 now:
    launchctl load ~/Library/LaunchAgents/homebrew.mxcl.php55.plist
Warning: Could not link php55. Unlinking...
Error: The `brew link` step did not complete successfully
The formula built, but is not symlinked into /usr/local
You can try again using `brew link php55'


  • php54インストール済みの自分の環境ではbrew linkでエラーが出てるのでphp54をunlinkしてから再度実行
brew unlink php54
brew link php55
  • PEARをインストールしてるので権限周りの修正
chmod -R ug+w /usr/local/Cellar/php55/5.5.4/lib/php
pear config-set php_ini /usr/local/etc/php/5.5/php.ini
  • icu4cライブラリが壊れてる?せいでintlオプションがエラーなので別途インストール
brew install php55-intl
  • php-fpmは現状自動起動不要なのでplistのコピーのみ


cp /usr/local/Cellar/php55/5.5.4/homebrew-php.josegonzalez.php55.plist ~/Library/LaunchAgents/
  • phpのwarningが出まくるのでtimezoneの設定追加
vim /usr/local/etc/php/5.5/php.ini
;date.timezone =  
date.timezone = 'Asia/Tokyo'
  • 確認
php -v
PHP 5.5.4 (cli) (built: Oct 14 2013 12:19:49)
Copyright (c) 1997-2013 The PHP Group
Zend Engine v2.5.0, Copyright (c) 1998-2013 Zend Technologies