0
1

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 1 year has passed since last update.

M1 MacPro にPHPをインストールする【homebrew】

Last updated at Posted at 2022-02-12

brewでPHPをインストールする

環境

  • M1 macOS Monterey 12.1
  • zsh

前提条件

brewは既にインストール済

PHPをインストール

まずhomebrewでインストールできるphpのバージョンを探します。

$ brew search php

現在インストールできるphp一覧が表示されるので、今回はphp@7.4をインストールします。

$ brew install php@7.4

PATHを通す

phpのパスを調べます。

$ brew --prefix php@7.4

わたしの場合/opt/homebrew/opt/php@7.4にインストールされてやした。

$ vim .zshrc
#下記のように書き込む(PATH={brew --prefix php@7.4で返ってくるパス}/bin:$PATH)
export PATH=/opt/homebrew/opt/php@7.4/bin:$PATH

.zshrcを読み込む

$ source .zshrc

確認

$ php -v

PHP 7.4.27 (cli) (built: Dec 16 2021 18:02:37) ( NTS )
Copyright (c) The PHP Group
Zend Engine v3.4.0, Copyright (c) Zend Technologies
with Zend OPcache v7.4.27, Copyright (c), by Zend Technologies

0
1
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
0
1

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?