気ままに

プログラム関連で困ったことを調べて気ままに投稿

【Mac】PHP7.1 をインストールしている時にlibzでエラーがでる

ローカル環境作っていて、phpを再インストールしようとした時に、libzが見つからないというエラーでインストールできなかった時の対処方法

以下、再インストールしようとした時のエラー

$brew reinstall php71
==> Reinstalling homebrew/php/php71 --with-postgresql
==> Downloading https://php.net/get/php-7.1.14.tar.bz2/from/this/mirror
Already downloaded: /Users/user/Library/Caches/Homebrew/php71-7.1.14
==> ./configure --prefix=/usr/local/Cellar/php71/7.1.14_25 --localstatedir=/usr/local/var --sysconfdir=/usr/local/etc/php/7.1 --with-config-file-path=/usr/local/etc/php/7.1 --with-config-file-scan-dir=/usr/local/etc/php/7.1/conf.d --mandir=/usr/local/Cellar/php71/7.1.14_25/share/man --enabl
Last 15 lines from /Users/user/Library/Logs/Homebrew/php71/01.configure:
checking for Kerberos support... /usr
checking whether to use system default cipher list instead of hardcoded value... no
checking for krb5-config... /usr/bin/krb5-config
checking for RAND_egd... no
checking for pkg-config... no
checking for OpenSSL version... >= 1.0.1
checking for CRYPTO_free in -lcrypto... yes
checking for SSL_CTX_set_ssl_version in -lssl... yes
checking for PCRE library to use... bundled
checking whether to enable PCRE JIT functionality... yes
checking whether to enable the SQLite3 extension... yes
checking bundled sqlite3 library... yes
checking for ZLIB support... yes
checking if the location of ZLIB install directory is defined... no
configure: error: Cannot find libzconfigure: error: Cannot find libz

READ THIS: https://docs.brew.sh/Troubleshooting.html

These open issues may also help:
php71 mongoDB ext crashing php https://github.com/Homebrew/homebrew-php/issues/4607

原因は、久しぶりになったx-codeのアップデートが原因で、実行できなくなっていた。 以下のコマンドでx-codeをインストール

xcode-select --install

すると無事にphp の再インストールが完了。

 $ brew reinstall php71
==> Reinstalling homebrew/php/php71 --with-postgresql
==> Downloading https://php.net/get/php-7.1.14.tar.bz2/from/this/mirror
Already downloaded: /Users/user/Library/Caches/Homebrew/php71-7.1.14
==> ./configure --prefix=/usr/local/Cellar/php71/7.1.14_25 --localstatedir=/usr/local/var --sysconfdir=/usr/local/etc/php/7.1 --with-config-file-path=/usr/local/etc/php/7.1 --with-config-file-scan-dir=/usr/local/etc/php/7.1/conf.d --mandir=/usr/local/Cellar/php71/7.1.14_25/share/man --enabl
==> make
==> make install
==> Caveats
The php.ini file can be found in:
    /usr/local/etc/php/7.1/php.ini

✩✩✩✩ Extensions ✩✩✩✩

If you are having issues with custom extension compiling, ensure that you are using the brew version, by placing /usr/local/bin before /usr/sbin in your PATH:

      PATH="/usr/local/bin:$PATH"

PHP71 Extensions will always be compiled against this PHP. Please install them using --without-homebrew-php to enable compiling against system PHP.

✩✩✩✩ PHP CLI ✩✩✩✩

If you wish to swap the PHP you use on the command line, you should add the following to ~/.bashrc, ~/.zshrc, ~/.profile or your shell's equivalent configuration file:
  export PATH="$(brew --prefix homebrew/php/php71)/bin:$PATH"

✩✩✩✩ FPM ✩✩✩✩

To launch php-fpm on startup:
    mkdir -p ~/Library/LaunchAgents
    cp /usr/local/opt/php71/homebrew.mxcl.php71.plist ~/Library/LaunchAgents/
    launchctl load -w ~/Library/LaunchAgents/homebrew.mxcl.php71.plist

The control script is located at /usr/local/opt/php71/sbin/php71-fpm

OS X 10.8 and newer come with php-fpm pre-installed, to ensure you are using the brew version you need to make sure /usr/local/sbin is before /usr/sbin in your PATH:

  PATH="/usr/local/sbin:$PATH"

You may also need to edit the plist to use the correct "UserName".

Please note that the plist was called 'homebrew-php.josegonzalez.php71.plist' in old versions of this formula.

With the release of macOS Sierra the Apache module is now not built by default. If you want to build it on your system you have to install php with the --with-httpd option. See  brew options php71 for more details.

By 31st March 2018 we will deprecate and archive the PHP tap.
Some of the formulae will be migrated to homebrew-core.

For more details, see https://github.com/Homebrew/homebrew-php/issues/4721

To restart homebrew/php/php71 after an upgrade:
  brew services restart homebrew/php/php71
==> Summary
🍺  /usr/local/Cellar/php71/7.1.14_25: 345 files, 39.6MB, built in 5 minutes 3 seconds

最近、Railsは触っているだけで新しいことやってないな。PHP関連が続いたので、そろそろRailsもやりたいと思いつつ、 しばらくはPHP三昧になりそうです。