logo-sm

お問い合わせは Webフォームから

ブログ

Macにanyenvでphp7.0.21を入れた時のトライ&エラーの結果

2017.12.15

[markdown]
@naganohrfmです。
あっという間に一年が過ぎ去っていきます。来年はどんな年になるか今から楽しみです。

さて今まで**rbenv**や**pyenv**と個別に管理していたのですが、
phpも検証で使う必要が出てきたため、
**anyenv**なるものがあるということで早速導入いたしました。
**rbenv**や**pyenv**は今までとおりにあっさりと完了しました。。。が

**phpenv**での導入にはトライアンドエラーが必要だったため、
先人の知恵を拝借しながらその手順を備忘録変わりに記載いたします。

# 前提として以下がすでに導入されていることとなります。
* Homebrew
* anyenv

## マシン情報
* macOS Sierra 10.12.6
* Xcode9
* php 7.0.21

## 必要なモジュールをhomebrew経由でインストールする。
“`
$ brew install openssl \
gcc re2c \
libmcrypt autoconf \
automake libiconv \
libxml2 libjpeg \
libpng intltool icu4c
“`

## デフォルトのコンフィグのオプションをbrewで導入したモジュールのパスなどに合わせる。
私の環境では以下のことを行いました。
* –with-mcryptのパスを**which mcrypt**で出力されたパスに書き換えました。
* –with-libxml-dirのパスを**brew install libxml2**で画面に出力されたパスに書き換えました。
* –with-opensslのパスを**which openssl**で出力されたパスに書き換えました。
* –enable-soap/は不要だったのでdefault_configure_optionsファイルから削除をしました。

“`
$ vi $HOME/.anyenv/envs/phpenv/plugins/php-build/share/php-build/default_configure_options

–without-pear
–with-gd
–enable-sockets
–with-jpeg-dir=/usr
–with-png-dir=/usr
–enable-exif
–enable-zip
–with-zlib
–with-zlib-dir=/usr
–with-bz2
–enable-intl
–with-kerberos
–with-openssl
–with-mcrypt=/usr/local/bin/mcrypt ← which mcryptのパス。
–enable-xmlreader
–with-xsl
–enable-ftp
–enable-cgi
–with-curl=/usr
–with-tidy
–with-xmlrpc
–with-libxml-dir=/usr/local/Cellar/libxml2 ← brew installした時に出力されたパス。
–with-openssl=/usr/bin/openssl ← which opensslのパス。
–enable-sysvsem
–enable-sysvshm
–enable-shmop
–with-mysqli=mysqlnd
–with-pdo-mysql=mysqlnd
–with-pdo-sqlite
–enable-pcntl
–with-readline
–enable-mbstring
–disable-debug
–enable-fpm
–enable-bcmath
–enable-phpdbg
“`

## phpenvでインストールする。
なお**Xcode9**をインストールされていると
**ld: file not found: /usr/lib/system/libsystem_darwin.dylib for architecture x86_64**
と出力されてしまいます。以前と名称が違うようです。
なので**LDFLAGS**という環境変数にパスを指定してphpenvでインストールを行っています。
“`
$ LDFLAGS=”-L/Library/Developer/CommandLineTools/SDKs/MacOSX.sdk/usr/lib/system” phpenv install 7.0.21
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.0.21 into /Users/wantata222/.anyenv/envs/phpenv/versions/7.0.21
[Skipping]: Already downloaded and extracted https://secure.php.net/distributions/php-7.0.21.tar.bz2
[Preparing]: /var/tmp/php-build/source/7.0.21
[Compiling]: /var/tmp/php-build/source/7.0.21
[xdebug]: Installing version 2.5.5
[Downloading]: http://xdebug.org/files/xdebug-2.5.5.tgz
[xdebug]: Compiling xdebug in /var/tmp/php-build/source/xdebug-2.5.5
[xdebug]: Installing xdebug configuration in /Users/wantata222/.anyenv/envs/phpenv/versions/7.0.21/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.21.20171215172802.log
[Success]: Built 7.0.21 successfully.
“`

[/markdown]

関連記事

  • WindowsのWSL2上のDockerでup時に’ContainerConfig’のエラーが出た。
    当社の開発環境はMacとWindowsが混在したDocker上での開発を行っています。なのでMacでOKだけど […]

    2024.04.08

  • VSCode (内のPowerShell)でアドレス設定を切り替え!
    【経緯】 最近携わった案件で大量のNW機器のキッティングをした際、それぞれにSSHでの接続性などを確認するテス […]

    2023.10.13

  • PaloaltoでWindows NTPサーバに同期
    【事象と対処法】 オフライン環境のPaloaltoでNTPの機能確認をする必要があり、Windows標準のNT […]

    2023.10.13

  • パートナー

  • 人材育成・採用情報