15
14

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?

More than 5 years have passed since last update.

Macでphpenv + php-buildによる環境構築した際にハマった時のメモ(OpenSSLとか)

Last updated at Posted at 2015-10-14

Mac(10.11, El Capitan)でphpenv+php-buildを使ってPHP環境を整えようとした時に地味にハマったので書き残しておく。

エラー内容

phpenvとphp-buildは既に入っているとして、PHP5.5.27をインストールしようとしたら以下のエラーが出た。

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

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

Here are the last 10 lines from the log:

-----------------------------------------
configure: error: Cannot find OpenSSL's <evp.h>
-----------------------------------------

The full Log is available at '/tmp/php-build.5.5.27.20151014105208.log'.
[Warn]: Aborting build.

opensslを入れてみるが"installed"とのこと。

$ brew install openssl
Warning: openssl already installed

多分バージョン変えたほうが良さそう。

opensslのバージョンを変える

$ brew search openssl
homebrew/versions/openssl098				      openssl (installed)
homebrew/versions/openssl101
brew install homebrew/versions/openssl101

openssl101はkeg-onlyとのことなので自分でbrew linkする。

$ brew link --force homebrew/versions/openssl101

PHPインストールしたらまたエラー

本記事で扱った依存関係以外については以下の記事参照。
http://qiita.com/tebonz/items/82ad7e57066650d43b28

$ phpenv install 5.5.27


[Info]: Loaded extension plugin
[Info]: Loaded apc Plugin.
[Info]: Loaded composer Plugin.
[Info]: Loaded pyrus Plugin.
[Info]: Loaded uprofiler Plugin.
[Info]: Loaded xdebug Plugin.
[Info]: Loaded xhprof Plugin.
[Info]: php.ini-production gets used as php.ini
[Info]: Building 5.5.27 into /Users/foo/.phpenv/versions/5.5.27
[Skipping]: Already downloaded and extracted https://secure.php.net/distributions/php-5.5.27.tar.bz2
[Preparing]: /var/tmp/php-build/source/5.5.27
[Compiling]: /var/tmp/php-build/source/5.5.27

[Pyrus]: Downloading from http://pear2.php.net/pyrus.phar
[Pyrus]: Installing executable in /Users/foo/.phpenv/versions/5.5.27/bin/pyrus
[xdebug]: Installing version 2.3.3
[xdebug]: Compiling xdebug in /var/tmp/php-build/source/xdebug-2.3.3

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

Here are the last 10 lines from the log:

-----------------------------------------
1 warning generated.
/var/tmp/php-build/source/5.5.27/sapi/cli/php_cli_server.c:541:25: warning: address of '(sapi_globals.sapi_headers).headers' will always evaluate to 'true' [-Wpointer-bool-conversion]
        if (!&SG(sapi_headers).headers) {
            ~ ~~~~~~~~~~~~~~~~~^~~~~~~
1 warning generated.
/var/tmp/php-build/source/5.5.27/sapi/cgi/cgi_main.c:1700:25: warning: address of '(sapi_globals.sapi_headers).headers' will always evaluate to 'true' [-Wpointer-bool-conversion]
        if (!&SG(sapi_headers).headers) {
            ~ ~~~~~~~~~~~~~~~~~^~~~~~~
1 warning generated.
PEAR package PHP_Archive not installed: generated phar will require PHP's phar extension be enabled.
-----------------------------------------

The full Log is available at '/tmp/php-build.5.5.27.20151014105609.log'.
[Warn]: Aborting build.

↓を参考にautoconfautomakeをインストール。ありがとうございました!
http://qiita.com/omega999/items/c5b1c177331f8d342efd

$ brew install autoconf
$ brew install automake

ようやくインストール成功

$ phpenv install 5.5.27
[Info]: Loaded extension plugin
[Info]: Loaded apc Plugin.
[Info]: Loaded composer Plugin.
[Info]: Loaded pyrus Plugin.
[Info]: Loaded uprofiler Plugin.
[Info]: Loaded xdebug Plugin.
[Info]: Loaded xhprof Plugin.
[Info]: php.ini-production gets used as php.ini
[Info]: Building 5.5.27 into /Users/foo/.phpenv/versions/5.5.27
[Skipping]: Already downloaded and extracted https://secure.php.net/distributions/php-5.5.27.tar.bz2
[Preparing]: /var/tmp/php-build/source/5.5.27
[Compiling]: /var/tmp/php-build/source/5.5.27
[Pyrus]: Downloading from http://pear2.php.net/pyrus.phar
[Pyrus]: Installing executable in /Users/foo/.phpenv/versions/5.5.27/bin/pyrus
[xdebug]: Installing version 2.3.3
[xdebug]: Compiling xdebug in /var/tmp/php-build/source/xdebug-2.3.3
[xdebug]: Installing xdebug configuration in /Users/foo/.phpenv/versions/5.5.27/etc/conf.d/xdebug.ini
[xdebug]: Cleaning up.
[Info]: Enabling Opcache...
[Info]: Done
[Info]: The Log File is not empty, but the Build did not fail. Maybe just warnings got logged. You can review the log in /tmp/php-build.5.5.27.20151014112846.log
[Success]: Built 5.5.27 successfully.
$ phpenv global 5.5.27
$ php -v
PHP 5.5.27 (cli) (built: Oct 14 2015 11:38:58)
Copyright (c) 1997-2015 The PHP Group
Zend Engine v2.5.0, Copyright (c) 1998-2015 Zend Technologies
    with Zend OPcache v7.0.6-dev, Copyright (c) 1999-2015, by Zend Technologies
    with Xdebug v2.3.3, Copyright (c) 2002-2015, by Derick Rethans
15
14
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
15
14

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?