1
0

PHP 8.2のインストール

Last updated at Posted at 2023-09-24

PHP 8.X系をインストールしたので、手順を備忘録として残しておきます。

経緯

AWSを使用したPHPのアプリを何か作りたいと考えていて、Laravelを使うべくインストールしようとしたら、自前のMacにPHPが入っていないことに気付かされる。

環境

macOS Monterey version 12.3.1
Homebrew 4.1.2

前提

Homebrewのインストールは下記参照。
https://aiacademy.jp/media/?p=2817

Homebrewは入っていたので、Composer入れるべく、OpenSSLのインストール。
% brew install openssl
次に、以下のコマンドでComposerをインストール…
% curl -sS http://getcomposer.org/installer | php
しようとしたところ、下記のエラーが出てきた。

zsh: command not found: php
curl: (23) Failure writing output to destination

「PHPがないの…?」
% php -v
ないらしい。

% php -v
zsh: command not found: php

Homebrewのアップグレードをやってみたら何か解決するかもしれないと考え、とりあえずアップグレード。

% brew upgrade
==> Downloading https://formulae.brew.sh/api/formula.jws.json
#=#=#                                                                          
==> Upgrading 4 outdated packages:
brotli 1.0.9 -> 1.1.0
grep 3.7 -> 3.11
nodebrew 1.1.0 -> 1.2.0
tfenv 2.2.3 -> 3.0.0

解決したかなと、とりあえずネットで探したコマンドでPHPインストール試みる。

% brew install php@7.4
Error: php@7.4 has been disabled because it is a versioned formula!

7.4は古いバージョンでサポート対象外、というエラーらしい。

結局

下記のコマンドで最新のPHPをインストール出来、解決した模様。

% brew install php
==> Downloading https://ghcr.io/v2/homebrew/core/php/manifests/8.2.10

Composerもバッチリ。

% curl -sS http://getcomposer.org/installer | php
All settings correct for using Composer
Downloading...

Composer (version 2.6.3) successfully installed to: /Users/masaki/Desktop/Bifree/ciel-app/02_app/composer.phar
Use it: php composer.phar

% php composer.phar
   ______
  / ____/___  ____ ___  ____  ____  ________  _____
 / /   / __ \/ __ `__ \/ __ \/ __ \/ ___/ _ \/ ___/
/ /___/ /_/ / / / / / / /_/ / /_/ (__  )  __/ /
\____/\____/_/ /_/ /_/ .___/\____/____/\___/_/

このままだと結局使えないので、

% composer --version                
zsh: command not found: composer

パスを通すこともお忘れなく。

% sudo mv composer.phar /usr/local/bin/composer
Password:
% composer --version
Composer version 2.6.3 2023-09-15 09:38:21
1
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
1
0