今からお前んちこいよ

ベルリンにて細々とお勉強。

Mac + phpenv で php7.1.9 を入れる

日本語 | English

Mac OS (Sierra/10.12.3)

phpenv

brewで入らなかったので手動。

# 配置
$ cd
$ git clone https://github.com/CHH/phpenv.git
$ cd phpenv/bin
$ ./phpenv-install.sh
# ---> $HOME/.phpenv が出来上がる

# お掃除
$ cd 
$ rm -rf phpenv

パスを通す。

$ echo 'export PATH="$HOME/.phpenv/bin:$PATH"' >> ~/.bash_profile
$ echo 'eval "$(phpenv init -)"' >> ~/.bash_profile
$ source ~/.bash_profile
$ phpenv versions
* system (set by /Users/XXXX/.phpenv/version)

phpenv install 7.1.9

ビルドするために php-build を phpenv に入れる。

$ git clone https://github.com/CHH/php-build.git ~/.phpenv/plugins/php-build

インストール可能バージョン一覧。

$ phpenv install --list
Available versions:
  5.2.17
  5.3.10
  5.3.11
~~~ 略 ~~~
  7.1.9

今回は 7.1.9 を入れる。

$ phpenv install 7.1.9

~~~ 略 ~~~

-----------------
|  BUILD ERROR  |
-----------------

Here are the last 10 lines from the log:

-----------------------------------------
configure: WARNING: This bison version is not supported for regeneration of the Zend/PHP parsers (found: 2.3, min: 204, excluded: ).
configure: WARNING: You will need re2c 0.13.4 or later if you want to regenerate PHP parsers.
configure: error: OpenSSL version 1.0.1 or greater required.
-----------------------------------------

もろもろパッケージが足りなくてエラーがでるので、
brewでインストールする。

$ brew install gcc re2c libmcrypt autoconf automake libiconv bison openssl libxml2 jpeg libpng
$ brew link --force bison
$ brew link --force openssl
$ brew link --force libxml2

再度 php7.1.9 をインストール。

$ phpenv install 7.1.9
[Info]: Loaded extension plugin
[Info]: Loaded apc Plugin.
[Info]: Loaded composer Plugin.
[Info]: Loaded github Plugin.
[Info]: Loaded uprofiler Plugin.
[Info]: Loaded xdebug Plugin.
[Info]: Loaded xhprof Plugin.
[Info]: Loaded zendopcache Plugin.
[Info]: php.ini-production gets used as php.ini
[Info]: Building 7.1.9 into /Users/XXXX/.phpenv/versions/7.1.9
[Skipping]: Already downloaded and extracted https://secure.php.net/distributions/php-7.1.9.tar.bz2
[Preparing]: /var/tmp/php-build/source/7.1.9
[Compiling]: /var/tmp/php-build/source/7.1.9
[Success]: Built 7.1.9 successfully.

成功したっぽい

$ phpenv versions
* system (set by /Users/XXXX/.phpenv/version)
  7.1.9
$ phpenv global 7.1.9
$ php -v
PHP 7.1.9 (cli) (built: Sep 16 2017 15:51:12) ( NTS )