LoginSignup
8
7

More than 5 years have passed since last update.

OSXで最新のPHPをビルドする方法

Last updated at Posted at 2015-05-30

OSXで最新のPHP ( https://github.com/php/php-src ) を取得してビルドする方法を紹介します。

必要なもの

  • homebrew
  • git

homebrewで必要なものをインストール

brew install git
brew install re2c
brew install bison
brew install autoconf

homebrewはbisonへのパスを自動で通さないので、bisonが入った場所をメモしておきましょう。後で使います。

php-srcを取得

git clone https://github.com/php/php-src.git

configure

cd php-src
./buildconf
export YACC="/usr/local/Cellar/bison/3.0.4/bin/bison"
prefix="/opt/php-master"
./configure --prefix=$prefix \
--enable-cli \
--enable-mbstring \
--enable-json

インストール先を変えたい場合はprefixを変更してください。

ビルド

make
sudo make install

もうちょっとconfigure オプションを足したいときは

こんな感じでオプションを追加します。

--enable-xml \
--enable-zip \
--enable-ftp \
--enable-exif \
--enable-fileinfo \
--enable-pcntl \
--enable-pdo \
--with-curl \
--with-gd \
--with-curl=/usr \
--with-openssl \

(ちなみに私の環境だと--enable-intl, --enable-fpm あたりがうまく入らなかったのであきらめました)

はまりポイント

tokenizerとかparserまわりでこういうエラーが出ることがあります。
当初、C言語ファイルにバグがあるのかと思っていろいろソースを読んでもチンプンカンプンで途方に暮れていたのですが、どうやら自分が古いbison(OSXのデフォルトのbison)を使っていたのが原因だったようです。

参考

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