LoginSignup
0
1

More than 1 year has passed since last update.

【PHP】MacM1でPHP7.4をインストールする方法

Posted at

利用環境

MacOS:BigSur
バージョン:11.6.1
チップ:Apple M1

PHPインストールの手順

※ここでは「Homebrew」はインストール済み前提で進めます。

念の為、Homebrewでアップデートが必要ないか確認しました。

ターミナル
brew doctor

ターミナル起動する前に「Rosettaを使用して開く」にチェックをつけておきます。
参考資料:https://blog.looseknot.jp/mac/m1mac_terminal_rosetta.html

確認後、ターミナルを起動し下記を実行
※管理者パスワードが求められます

ターミナル
/bin/bash -c "$(curl -fsSL https://raw.githubusercontent.com/Homebrew/install/HEAD/install.sh)"

次にPHPをインストールします。

ターミナル
brew install php@7.4

インストールが無事に終わったら続いてpathを通します。

ターミナル
echo 'export PATH="/usr/local/opt/php@7.4/bin:$PATH"' >> ~/.zshrc
echo 'export PATH="/usr/local/opt/php@7.4/sbin:$PATH"' >> ~/.zshrc

最後にPHPの再起動

ターミナル
brew services start php@7.4

バージョンを確認し問題なければ完了です。

ターミナル
php -v
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