2
2

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 3 years have passed since last update.

MacOSをCatalinaにしてphpが動作しなくなったら

Posted at

MacOSのバージョンアップ時の定期事故である、phpenvの再インストール

phpが動かなくなった時の対応

よくmacosのバージョンをあげたらいきなりphpが動かなくなることが多いです。
今まで毎回そうだったのでもう定期事故として考えています。面倒だけど、仕方なく新しいの使いたいから今回もバージョンアップ!

$ php -v
dyld: Library not loaded: /usr/local/opt/icu4c/lib/libicui18n.64.dylib
  Referenced from: /Users/syokatsu/.phpenv/versions/7.3.13/bin/php
  Reason: image not found
zsh: abort      php -v

やはりこれか〜!
icu4cの問題は以前もあったので、気軽に次のステップへ

まずはphp-buildのバージョンアップから!

php-buildのバージョンアップ

$ cd ~/.phpenv/plugins/php-build
$ git pull

今まではphp7.3系を利用していたが、php7.4が落ちてきたのでそろそろphp7.4系をinstallすることに!

php7.4のinstall

関連libraryインストール。必要なのは色々あるはずなので、必要な物をinstall

$ brew install bzip2 icu4c krb5 libedit libzip oniguruma openssl@1.1 pkg-config tidy-html5
$ vi ~/.phpenv/plugins/php-build/share/php-build/default_configure_options
~~
この内容を追加
--with-zlib-dir=/usr/local/opt/zlib
--with-bz2=/usr/local/opt/bzip2
--with-libedit=/usr/local/opt/libedit
~~

$ vi ~/.zshrc
export PKG_CONFIG_PATH="/usr/local/opt/krb5/lib/pkgconfig:/usr/local/opt/icu4c/lib/pkgconfig:/usr/local/opt/libedit/lib/pkgconfig:/usr/local/opt/libjpeg/lib/pkgconfig:/usr/local/opt/libpng/lib/pkgconfig:/usr/local/opt/libxml2/lib/pkgconfig:/usr/local/opt/libzip/lib/pkgconfig:/usr/local/opt/oniguruma/lib/pkgconfig:/usr/local/opt/openssl@1.1/lib/pkgconfig:/usr/local/opt/tidy-html5/lib/pkgconfig" 

phpのinstall

$ phpenv install 7.4.6
...
[Success]: Built 7.4.6 successfully.

$ phpenv global 7.4.6
$ php -v
PHP 7.4.6 (cli) (built: May 23 2020 01:07:57) ( NTS )
Copyright (c) The PHP Group
Zend Engine v3.4.0, Copyright (c) Zend Technologies
    with Zend OPcache v7.4.6, Copyright (c), by Zend Technologies
    with Xdebug v2.9.5, Copyright (c) 2002-2020, by Derick Rethans
2
2
1

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

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?