17
17

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.

brew link openssl --force ができなくて phpenv & php-build で PHP がビルドできない

Posted at

問題

phpenv install でビルドが OpenSSL が無いエラーでこける

Mac OS X El CapitanにNginx + phpenv + php-build + php-fpmの環境を構築する手順
と同様の状況。
brew で OpenSSL はインストール済みだけど OSX のものを使うようになっていて、OSX (El Capitan) の OpenSSL には ヘッダファイルがない
参考: Mac OS X El CapitanからOpenSSLのヘッダファイルが消えた話

brew で入れた OpenSSL を使うようにしたく、
brew link openssl --force
と実行したが下記のメッセージが出力される

$ brew link openssl --force
Warning: Refusing to link: openssl
Linking keg-only openssl means you may end up linking against the insecure,
deprecated system OpenSSL while using the headers from Homebrew's openssl.
Instead, pass the full include/library paths to your compiler e.g.:
  -I/usr/local/opt/openssl/include -L/usr/local/opt/openssl/lib

brew で openssl をリンクできなくしたようで、コンパイラにパスを渡してねって言ってる
(Homebrew/brew link: don't link openssl. #597)

なんか .NET Core の話してる…なんとなく察した

解決

参考: Mac OS X El Capitan上でphp-buildするメモ

PHP_BUILD_CONFIGURE_OPTS="--with-openssl=$(brew --prefix openssl) --with-libxml-dir=$(brew --prefix libxml2)"

と、環境変数を渡すことでビルドできた

$ phpenv install 7.0.2
[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]: php.ini-production gets used as php.ini
[Info]: Building 7.0.2 into /Users/chatii/.phpenv/versions/7.0.2
[Skipping]: Already downloaded and extracted https://secure.php.net/distributions/php-7.0.2.tar.bz2
[Preparing]: /var/tmp/php-build/source/7.0.2
[Compiling]: /var/tmp/php-build/source/7.0.2
[xdebug]: Installing version 2.4.0
[xdebug]: Compiling xdebug in /var/tmp/php-build/source/xdebug-2.4.0
[xdebug]: Installing xdebug configuration in /Users/chatii/.phpenv/versions/7.0.2/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.7.0.2.20160804145836.log
[Success]: Built 7.0.2 successfully.

めでたしめでたし

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

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?