4
0

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 Montereyで"zsh: command not found: php"が出る際の対応方法

Posted at

MacBook Pro M1 Proが手元に届いたので、開発環境を整えてzshでhomebrewインストールも完了。PHP@7.4をインストールしてPATHを通すところでつまづいた。

php -v

をしても

zsh: command not found: php

が表示されてしまう。

brew list | grep php

では問題なくPHP@7.4が表示されるのでおかしい。

結論、リンクが必要だった。

macOS MontereyのPHPインストール手順としては、

brew install php@7.4
brew link --overwrite --force php@7.4

するとそこに表示される

echo 'export PATH="/opt/homebrew/opt/php@7.4/bin:$PATH"' >> ~/.zshrc
  echo 'export PATH="/opt/homebrew/opt/php@7.4/sbin:$PATH"' >> ~/.zshrc

を実行。

source ~/.zshrc

をすると、無事にPHPが認識された。

PHP 7.4.26 (cli) (built: Nov 18 2021 15:10:22) ( NTS )
Copyright (c) The PHP Group
Zend Engine v3.4.0, Copyright (c) Zend Technologies
    with Zend OPcache v7.4.26, Copyright (c), by Zend Technologies
4
0
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
4
0

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?