【初心者必見】HomebrewでPHPのインストールする方法

2023年5月10日PHP

kamiです。
TwitterYoutubeもやってます。

みなさんPHPはインストール済みですか?
この記事はMacにPHPをインストール方法の紹介です。
HomebrewでPHPをインストールします。
Homebrewについて知識がない方へPHPのパッケージのインストールについての紹介です。

この記事でわかること

  • Homebrewのインストール
  • Homebrewを使ってPHPのインストール
  • おすすめのパッケージマネージャー

この記事を最後まで読めば「Homebrewとは」から「PHPのインストール」までの理解が深まりますので、最後まで読んで「PHP」のインストールしましょう。

それでは順に見ていきましょう。

HomebrewでPHPのインストールする方法の全体の流れ

icon

HomebrewでPHPのインストールするには次の流れになります。

Homebrewのインストール確認

brew -v

バージョンが返ってくれば、インストール済みです。
パッケージをインストールしましょう。

バージョンが返ってこなければ、Homebrewをインストールしましょう。

スポンサードサーチ

Homebrewのインストール

Homebrewのインストール

homebrew install

Homebrewのバージョンでインストール済みの確認

brew -v

先ほどと同様に「brew -v」で確認します。

Homebrew 3.6.17
Homebrew/homebrew-core (git revision f0094f68a68; last commit 2023-01-03)

バージョンが返ってくれば、インストール済みです。

スポンサードサーチ

Homebrewを使ってパッケージをインストール

icon

homebrewを使ってパッケージをインストールします。

brew install パッケージ名

「brew install パッケージ名」で任意のパッケージ名をインストールできます。

PHPのインストール

PHPのインストール

brew install php

install実行結果

brew install php
Running `brew update --auto-update`...
==> Auto-updated Homebrew!
Updated 1 tap (homebrew/core).
==> New Formulae
aptos               ruby@3.1            video-compare       xorg-server
kubent              simdutf             xinit               xrdb
quartz-wm           twm                 xmodmap

==> Fetching dependencies for php: apr, ca-certificates, openssl@1.1, apr-util, argon2, aspell, m4, autoconf, brotli, gettext, libunistring, libidn2, libnghttp2, libssh2, openldap, rtmpdump, lz4, xz, zstd, curl, libtool, unixodbc, freetds, libpng, freetype, fontconfig, jpeg-turbo, giflib, highway, imath, openexr, libtiff, webp, jpeg-xl, libvmaf, aom, libavif, gd, gmp, icu4c, krb5, libpq, libsodium, libzip, oniguruma, pcre2, readline, sqlite and tidy-html5
==> Fetching apr
==> Downloading https://ghcr.io/v2/homebrew/core/apr/manifests/1.7.0_3
Already downloaded: /Users/kami/Library/Caches/Homebrew/downloads/e0d297efccde0e78fc4eadf749b58ce311387aad01c3c32ae65ef40586007c57--apr-1.7.0_3.bottle_manifest.json
==> Downloading https://ghcr.io/v2/homebrew/core/apr/blobs/sha256:02e6b44b3284fa
Already downloaded: /Users/kami/Library/Caches/Homebrew/downloads/cfc60c720dc8d7fc68b696ed37d4dd34ae384763b0af4090935bc30434c14763--apr--1.7.0_3.arm64_monterey.bottle.tar.gz
==> Fetching ca-certificates
==> Downloading https://ghcr.io/v2/homebrew/core/ca-certificates/manifests/2022-
Already downloaded: /Users/kami/Library/Caches/Homebrew/downloads/c81c08bc98b6af7470d978a65611767875a70965b6e8ba34e09d15d8c0314db8--ca-certificates-2022-10-11.bottle_manifest.json
==> Downloading https://ghcr.io/v2/homebrew/core/ca-certificates/blobs/sha256:1b
Already downloaded: /Users/kami/Library/Caches/Homebrew/downloads/275b8484c042a29b1e9d4f226f78c66b3377808c9b33c9836d1f77c55761e843--ca-certificates--2022-10-11.all.bottle.tar.gz
==> Fetching openssl@1.1
==> Downloading https://ghcr.io/v2/homebrew/core/openssl/1.1/manifests/1.1.1s
Already downloaded: /Users/kami/Library/Caches/Homebrew/downloads/0bd540a808ade4448d977fc4dc9711d8ea9a9b36a677e29a00f8ef821f7be88b--openssl@1.1-1.1.1s.bottle_manifest.json
==> Downloading https://ghcr.io/v2/homebrew/core/openssl/1.1/blobs/sha256:c11b17
Already downloaded: /Users/kami/Library/Caches/Homebrew/downloads/3cc9dc0fde0d3b0b171bdb934a98dc4d8a158859b9af3b9a611cee3cb7282ceb--openssl@1.1--1.1.1s.arm64_monterey.bottle.tar.gz
==> Fetching apr-util
==> Downloading https://ghcr.io/v2/homebrew/core/apr-util/manifests/1.6.1_4
Already downloaded: /Users/kami/Library/Caches/Homebrew/downloads/c8733338819aaa338de1c1642d998b1e3463312647e01c2771b5fcd3d0e929a2--apr-util-1.6.1_4.bottle_manifest.json
==> Downloading https://ghcr.io/v2/homebrew/core/apr-util/blobs/sha256:3fbbe5ef9
Already downloaded: /Users/kami/Library/Caches/Homebrew/downloads/abf5d91a2335ef977201796097e9e65088eeae16dec5dd2960f0091fbc7e7aef--apr-util--1.6.1_4.arm64_monterey.bottle.tar.gz
==> Fetching argon2
==> Downloading https://ghcr.io/v2/homebrew/core/argon2/manifests/20190702_1
Already downloaded: /Users/kami/Library/Caches/Homebrew/downloads/1edde14bdb96d4a110df174fb14e59db91750d4b8d4834474e62450ae1ec81a5--argon2-20190702_1.bottle_manifest.json
==> Downloading https://ghcr.io/v2/homebrew/core/argon2/blobs/sha256:498cea03c8c
Already downloaded: /Users/kami/Library/Caches/Homebrew/downloads/4e5969651d4ed880033d9d7b16562c38f254815acb40ef2a894e2d839904663c--argon2--20190702_1.arm64_monterey.bottle.tar.gz
==> Fetching aspell
==> Downloading https://ghcr.io/v2/homebrew/core/aspell/manifests/0.60.8-1
Already downloaded: /Users/kami/Library/Caches/Homebrew/downloads/637f4cb043e2bb9c168ba9db4fb06cbfd7fe0e0b5c496d04df3f97489bec4e8b--aspell-0.60.8-1.bottle_manifest.json
==> Downloading https://ghcr.io/v2/homebrew/core/aspell/blobs/sha256:d75d3b4e292
==> Downloading from https://pkg-containers.githubusercontent.com/ghcr1/blobs/sh
######################################################################## 100.0%
==> Fetching m4
==> Downloading https://ghcr.io/v2/homebrew/core/m4/manifests/1.4.19
######################################################################## 100.0%
==> Downloading https://ghcr.io/v2/homebrew/core/m4/blobs/sha256:8e9fa0d7d946f7c
==> Downloading from https://pkg-containers.githubusercontent.com/ghcr1/blobs/sh
######################################################################## 100.0%
==> Fetching autoconf
==> Downloading https://ghcr.io/v2/homebrew/core/autoconf/manifests/2.71
######################################################################## 100.0%
==> Downloading https://ghcr.io/v2/homebrew/core/autoconf/blobs/sha256:a3d366c98
==> Downloading from https://pkg-containers.githubusercontent.com/ghcr1/blobs/sh
######################################################################## 100.0%
==> Fetching brotli
==> Downloading https://ghcr.io/v2/homebrew/core/brotli/manifests/1.0.9
######################################################################## 100.0%
==> Downloading https://ghcr.io/v2/homebrew/core/brotli/blobs/sha256:5e9bddd862b
==> Downloading from https://pkg-containers.githubusercontent.com/ghcr1/blobs/sh
######################################################################## 100.0%
==> Fetching gettext
==> Downloading https://ghcr.io/v2/homebrew/core/gettext/manifests/0.21.1
######################################################################## 100.0%
==> Downloading https://ghcr.io/v2/homebrew/core/gettext/blobs/sha256:356b52e24b
==> Downloading from https://pkg-containers.githubusercontent.com/ghcr1/blobs/sh
######################################################################## 100.0%
==> Fetching libunistring
==> Downloading https://ghcr.io/v2/homebrew/core/libunistring/manifests/1.1
######################################################################## 100.0%
==> Downloading https://ghcr.io/v2/homebrew/core/libunistring/blobs/sha256:4224b
==> Downloading from https://pkg-containers.githubusercontent.com/ghcr1/blobs/sh
######################################################################## 100.0%
==> Fetching libidn2
==> Downloading https://ghcr.io/v2/homebrew/core/libidn2/manifests/2.3.4_1
######################################################################## 100.0%
==> Downloading https://ghcr.io/v2/homebrew/core/libidn2/blobs/sha256:baf8ea3635
==> Downloading from https://pkg-containers.githubusercontent.com/ghcr1/blobs/sh
######################################################################## 100.0%
==> Fetching libnghttp2
==> Downloading https://ghcr.io/v2/homebrew/core/libnghttp2/manifests/1.51.0-1
######################################################################## 100.0%
==> Downloading https://ghcr.io/v2/homebrew/core/libnghttp2/blobs/sha256:0449303
==> Downloading from https://pkg-containers.githubusercontent.com/ghcr1/blobs/sh
######################################################################## 100.0%
==> Fetching libssh2
==> Downloading https://ghcr.io/v2/homebrew/core/libssh2/manifests/1.10.0
######################################################################## 100.0%
==> Downloading https://ghcr.io/v2/homebrew/core/libssh2/blobs/sha256:f9dab718cf
==> Downloading from https://pkg-containers.githubusercontent.com/ghcr1/blobs/sh
######################################################################## 100.0%
==> Fetching openldap
==> Downloading https://ghcr.io/v2/homebrew/core/openldap/manifests/2.6.3
######################################################################## 100.0%
==> Downloading https://ghcr.io/v2/homebrew/core/openldap/blobs/sha256:d3f0bdb0f
==> Downloading from https://pkg-containers.githubusercontent.com/ghcr1/blobs/sh
######################################################################## 100.0%
==> Fetching rtmpdump
==> Downloading https://ghcr.io/v2/homebrew/core/rtmpdump/manifests/2.4.20151223
######################################################################## 100.0%
==> Downloading https://ghcr.io/v2/homebrew/core/rtmpdump/blobs/sha256:f0787745f
==> Downloading from https://pkg-containers.githubusercontent.com/ghcr1/blobs/sh
######################################################################## 100.0%
==> Fetching lz4
==> Downloading https://ghcr.io/v2/homebrew/core/lz4/manifests/1.9.4
######################################################################## 100.0%
==> Downloading https://ghcr.io/v2/homebrew/core/lz4/blobs/sha256:284fa580570efd
==> Downloading from https://pkg-containers.githubusercontent.com/ghcr1/blobs/sh
######################################################################## 100.0%
==> Fetching xz
==> Downloading https://ghcr.io/v2/homebrew/core/xz/manifests/5.4.0
######################################################################## 100.0%
==> Downloading https://ghcr.io/v2/homebrew/core/xz/blobs/sha256:1872953eda5b672
==> Downloading from https://pkg-containers.githubusercontent.com/ghcr1/blobs/sh
######################################################################## 100.0%
==> Fetching zstd
==> Downloading https://ghcr.io/v2/homebrew/core/zstd/manifests/1.5.2-3
######################################################################## 100.0%
==> Downloading https://ghcr.io/v2/homebrew/core/zstd/blobs/sha256:844b957a277cd
==> Downloading from https://pkg-containers.githubusercontent.com/ghcr1/blobs/sh
######################################################################## 100.0%
==> Fetching curl
==> Downloading https://ghcr.io/v2/homebrew/core/curl/manifests/7.87.0
######################################################################## 100.0%
==> Downloading https://ghcr.io/v2/homebrew/core/curl/blobs/sha256:bb61fd89bf7b3
==> Downloading from https://pkg-containers.githubusercontent.com/ghcr1/blobs/sh
######################################################################## 100.0%
==> Fetching libtool
==> Downloading https://ghcr.io/v2/homebrew/core/libtool/manifests/2.4.7
######################################################################## 100.0%
==> Downloading https://ghcr.io/v2/homebrew/core/libtool/blobs/sha256:5f92327e52
==> Downloading from https://pkg-containers.githubusercontent.com/ghcr1/blobs/sh
######################################################################## 100.0%
==> Fetching unixodbc
==> Downloading https://ghcr.io/v2/homebrew/core/unixodbc/manifests/2.3.11
######################################################################## 100.0%
==> Downloading https://ghcr.io/v2/homebrew/core/unixodbc/blobs/sha256:41252118b
==> Downloading from https://pkg-containers.githubusercontent.com/ghcr1/blobs/sh
######################################################################## 100.0%
==> Fetching freetds
==> Downloading https://ghcr.io/v2/homebrew/core/freetds/manifests/1.3.16
######################################################################## 100.0%
==> Downloading https://ghcr.io/v2/homebrew/core/freetds/blobs/sha256:d915287c41
==> Downloading from https://pkg-containers.githubusercontent.com/ghcr1/blobs/sh
######################################################################## 100.0%
==> Fetching libpng
==> Downloading https://ghcr.io/v2/homebrew/core/libpng/manifests/1.6.39
######################################################################## 100.0%
==> Downloading https://ghcr.io/v2/homebrew/core/libpng/blobs/sha256:c437aaaf373
==> Downloading from https://pkg-containers.githubusercontent.com/ghcr1/blobs/sh
######################################################################## 100.0%
==> Fetching freetype
==> Downloading https://ghcr.io/v2/homebrew/core/freetype/manifests/2.12.1
######################################################################## 100.0%
==> Downloading https://ghcr.io/v2/homebrew/core/freetype/blobs/sha256:3e190f2fa
==> Downloading from https://pkg-containers.githubusercontent.com/ghcr1/blobs/sh
######################################################################## 100.0%
==> Fetching fontconfig
==> Downloading https://ghcr.io/v2/homebrew/core/fontconfig/manifests/2.14.1
######################################################################## 100.0%
==> Downloading https://ghcr.io/v2/homebrew/core/fontconfig/blobs/sha256:decbdcc
==> Downloading from https://pkg-containers.githubusercontent.com/ghcr1/blobs/sh
######################################################################## 100.0%
==> Fetching jpeg-turbo
==> Downloading https://ghcr.io/v2/homebrew/core/jpeg-turbo/manifests/2.1.4
######################################################################## 100.0%
==> Downloading https://ghcr.io/v2/homebrew/core/jpeg-turbo/blobs/sha256:c9dbfe3
==> Downloading from https://pkg-containers.githubusercontent.com/ghcr1/blobs/sh
######################################################################## 100.0%
==> Fetching giflib
==> Downloading https://ghcr.io/v2/homebrew/core/giflib/manifests/5.2.1
######################################################################## 100.0%
==> Downloading https://ghcr.io/v2/homebrew/core/giflib/blobs/sha256:6a1194d7b2d
==> Downloading from https://pkg-containers.githubusercontent.com/ghcr1/blobs/sh
######################################################################## 100.0%
==> Fetching highway
==> Downloading https://ghcr.io/v2/homebrew/core/highway/manifests/1.0.2
######################################################################## 100.0%
==> Downloading https://ghcr.io/v2/homebrew/core/highway/blobs/sha256:cdc2306692
==> Downloading from https://pkg-containers.githubusercontent.com/ghcr1/blobs/sh
######################################################################## 100.0%
==> Fetching imath
==> Downloading https://ghcr.io/v2/homebrew/core/imath/manifests/3.1.6
######################################################################## 100.0%
==> Downloading https://ghcr.io/v2/homebrew/core/imath/blobs/sha256:ff6169b5986b
==> Downloading from https://pkg-containers.githubusercontent.com/ghcr1/blobs/sh
######################################################################## 100.0%
==> Fetching openexr
==> Downloading https://ghcr.io/v2/homebrew/core/openexr/manifests/3.1.5
######################################################################## 100.0%
==> Downloading https://ghcr.io/v2/homebrew/core/openexr/blobs/sha256:633811a87f
==> Downloading from https://pkg-containers.githubusercontent.com/ghcr1/blobs/sh
######################################################################## 100.0%
==> Fetching libtiff
==> Downloading https://ghcr.io/v2/homebrew/core/libtiff/manifests/4.4.0_1-1
######################################################################## 100.0%
==> Downloading https://ghcr.io/v2/homebrew/core/libtiff/blobs/sha256:b48b8b5166
==> Downloading from https://pkg-containers.githubusercontent.com/ghcr1/blobs/sh
######################################################################## 100.0%
==> Fetching webp
==> Downloading https://ghcr.io/v2/homebrew/core/webp/manifests/1.2.4
######################################################################## 100.0%
==> Downloading https://ghcr.io/v2/homebrew/core/webp/blobs/sha256:f2857acd2c645
==> Downloading from https://pkg-containers.githubusercontent.com/ghcr1/blobs/sh
######################################################################## 100.0%
==> Fetching jpeg-xl
==> Downloading https://ghcr.io/v2/homebrew/core/jpeg-xl/manifests/0.7.0_1
######################################################################## 100.0%
==> Downloading https://ghcr.io/v2/homebrew/core/jpeg-xl/blobs/sha256:61c94c8298
==> Downloading from https://pkg-containers.githubusercontent.com/ghcr1/blobs/sh
######################################################################## 100.0%
==> Fetching libvmaf
==> Downloading https://ghcr.io/v2/homebrew/core/libvmaf/manifests/2.3.1
######################################################################## 100.0%
==> Downloading https://ghcr.io/v2/homebrew/core/libvmaf/blobs/sha256:780fe80d39
==> Downloading from https://pkg-containers.githubusercontent.com/ghcr1/blobs/sh
######################################################################## 100.0%
==> Fetching aom
==> Downloading https://ghcr.io/v2/homebrew/core/aom/manifests/3.5.0_1
######################################################################## 100.0%
==> Downloading https://ghcr.io/v2/homebrew/core/aom/blobs/sha256:8e185cf8b310b0
==> Downloading from https://pkg-containers.githubusercontent.com/ghcr1/blobs/sh
######################################################################## 100.0%
==> Fetching libavif
==> Downloading https://ghcr.io/v2/homebrew/core/libavif/manifests/0.11.1
######################################################################## 100.0%
==> Downloading https://ghcr.io/v2/homebrew/core/libavif/blobs/sha256:7894a74f1c
==> Downloading from https://pkg-containers.githubusercontent.com/ghcr1/blobs/sh
######################################################################## 100.0%
==> Fetching gd
==> Downloading https://ghcr.io/v2/homebrew/core/gd/manifests/2.3.3_4
######################################################################## 100.0%
==> Downloading https://ghcr.io/v2/homebrew/core/gd/blobs/sha256:22dba9b654ae0a2
==> Downloading from https://pkg-containers.githubusercontent.com/ghcr1/blobs/sh
######################################################################## 100.0%
==> Fetching gmp
==> Downloading https://ghcr.io/v2/homebrew/core/gmp/manifests/6.2.1_1
######################################################################## 100.0%
==> Downloading https://ghcr.io/v2/homebrew/core/gmp/blobs/sha256:a43a2ae4c44d90
==> Downloading from https://pkg-containers.githubusercontent.com/ghcr1/blobs/sh
######################################################################## 100.0%
==> Fetching icu4c
==> Downloading https://ghcr.io/v2/homebrew/core/icu4c/manifests/71.1
######################################################################## 100.0%
==> Downloading https://ghcr.io/v2/homebrew/core/icu4c/blobs/sha256:0bf3c66f005e
==> Downloading from https://pkg-containers.githubusercontent.com/ghcr1/blobs/sh
######################################################################## 100.0%
==> Fetching krb5
==> Downloading https://ghcr.io/v2/homebrew/core/krb5/manifests/1.20.1
######################################################################## 100.0%
==> Downloading https://ghcr.io/v2/homebrew/core/krb5/blobs/sha256:a6ef38ba592b8
==> Downloading from https://pkg-containers.githubusercontent.com/ghcr1/blobs/sh
######################################################################## 100.0%
==> Fetching libpq
==> Downloading https://ghcr.io/v2/homebrew/core/libpq/manifests/15.1
######################################################################## 100.0%
==> Downloading https://ghcr.io/v2/homebrew/core/libpq/blobs/sha256:93be59131fe5
==> Downloading from https://pkg-containers.githubusercontent.com/ghcr1/blobs/sh
######################################################################## 100.0%
==> Fetching libsodium
==> Downloading https://ghcr.io/v2/homebrew/core/libsodium/manifests/1.0.18_1
######################################################################## 100.0%
==> Downloading https://ghcr.io/v2/homebrew/core/libsodium/blobs/sha256:493ce4fa
==> Downloading from https://pkg-containers.githubusercontent.com/ghcr1/blobs/sh
######################################################################## 100.0%
==> Fetching libzip
==> Downloading https://ghcr.io/v2/homebrew/core/libzip/manifests/1.9.2
######################################################################## 100.0%
==> Downloading https://ghcr.io/v2/homebrew/core/libzip/blobs/sha256:e27a1b53f6b
==> Downloading from https://pkg-containers.githubusercontent.com/ghcr1/blobs/sh
######################################################################## 100.0%
==> Fetching oniguruma
==> Downloading https://ghcr.io/v2/homebrew/core/oniguruma/manifests/6.9.8
######################################################################## 100.0%
==> Downloading https://ghcr.io/v2/homebrew/core/oniguruma/blobs/sha256:6c66f5d4
==> Downloading from https://pkg-containers.githubusercontent.com/ghcr1/blobs/sh
######################################################################## 100.0%
==> Fetching pcre2
==> Downloading https://ghcr.io/v2/homebrew/core/pcre2/manifests/10.42
######################################################################## 100.0%
==> Downloading https://ghcr.io/v2/homebrew/core/pcre2/blobs/sha256:23ce93cf86bd
==> Downloading from https://pkg-containers.githubusercontent.com/ghcr1/blobs/sh
######################################################################## 100.0%
==> Fetching readline
==> Downloading https://ghcr.io/v2/homebrew/core/readline/manifests/8.2.1
######################################################################## 100.0%
==> Downloading https://ghcr.io/v2/homebrew/core/readline/blobs/sha256:9406afa0f
==> Downloading from https://pkg-containers.githubusercontent.com/ghcr1/blobs/sh
######################################################################## 100.0%
==> Fetching sqlite
==> Downloading https://ghcr.io/v2/homebrew/core/sqlite/manifests/3.40.1
######################################################################## 100.0%
==> Downloading https://ghcr.io/v2/homebrew/core/sqlite/blobs/sha256:45f18a632fd
==> Downloading from https://pkg-containers.githubusercontent.com/ghcr1/blobs/sh
######################################################################## 100.0%
==> Fetching tidy-html5
==> Downloading https://ghcr.io/v2/homebrew/core/tidy-html5/manifests/5.8.0
######################################################################## 100.0%
==> Downloading https://ghcr.io/v2/homebrew/core/tidy-html5/blobs/sha256:15f70f8
==> Downloading from https://pkg-containers.githubusercontent.com/ghcr1/blobs/sh
######################################################################## 100.0%
==> Fetching php
==> Downloading https://ghcr.io/v2/homebrew/core/php/manifests/8.2.1
######################################################################## 100.0%
==> Downloading https://ghcr.io/v2/homebrew/core/php/blobs/sha256:0902fca9a1bba8
==> Downloading from https://pkg-containers.githubusercontent.com/ghcr1/blobs/sh
######################################################################## 100.0%
==> Installing dependencies for php: apr, ca-certificates, openssl@1.1, apr-util, argon2, aspell, m4, autoconf, brotli, gettext, libunistring, libidn2, libnghttp2, libssh2, openldap, rtmpdump, lz4, xz, zstd, curl, libtool, unixodbc, freetds, libpng, freetype, fontconfig, jpeg-turbo, giflib, highway, imath, openexr, libtiff, webp, jpeg-xl, libvmaf, aom, libavif, gd, gmp, icu4c, krb5, libpq, libsodium, libzip, oniguruma, pcre2, readline, sqlite and tidy-html5
==> Installing php dependency: apr
==> Pouring apr--1.7.0_3.arm64_monterey.bottle.tar.gz
🍺  /opt/homebrew/Cellar/apr/1.7.0_3: 59 files, 1.4MB
==> Installing php dependency: ca-certificates
==> Pouring ca-certificates--2022-10-11.all.bottle.tar.gz
==> Regenerating CA certificate bundle from keychain, this may take a while...
🍺  /opt/homebrew/Cellar/ca-certificates/2022-10-11: 3 files, 225.5KB
==> Installing php dependency: openssl@1.1
==> Pouring openssl@1.1--1.1.1s.arm64_monterey.bottle.tar.gz
🍺  /opt/homebrew/Cellar/openssl@1.1/1.1.1s: 8,101 files, 18MB
==> Installing php dependency: apr-util
==> Pouring apr-util--1.6.1_4.arm64_monterey.bottle.tar.gz
🍺  /opt/homebrew/Cellar/apr-util/1.6.1_4: 54 files, 889KB
==> Installing php dependency: argon2
==> Pouring argon2--20190702_1.arm64_monterey.bottle.tar.gz
🍺  /opt/homebrew/Cellar/argon2/20190702_1: 12 files, 684.6KB
==> Installing php dependency: aspell
==> Pouring aspell--0.60.8.arm64_monterey.bottle.1.tar.gz
🍺  /opt/homebrew/Cellar/aspell/0.60.8: 767 files, 322.8MB
==> Installing php dependency: m4
==> Pouring m4--1.4.19.arm64_monterey.bottle.tar.gz
🍺  /opt/homebrew/Cellar/m4/1.4.19: 13 files, 742.5KB
==> Installing php dependency: autoconf
==> Pouring autoconf--2.71.arm64_monterey.bottle.tar.gz
🍺  /opt/homebrew/Cellar/autoconf/2.71: 71 files, 3.2MB
==> Installing php dependency: brotli
==> Pouring brotli--1.0.9.arm64_monterey.bottle.tar.gz
🍺  /opt/homebrew/Cellar/brotli/1.0.9: 25 files, 2.3MB
==> Installing php dependency: gettext
==> Pouring gettext--0.21.1.arm64_monterey.bottle.tar.gz
🍺  /opt/homebrew/Cellar/gettext/0.21.1: 1,983 files, 20.9MB
==> Installing php dependency: libunistring
==> Pouring libunistring--1.1.arm64_monterey.bottle.tar.gz
🍺  /opt/homebrew/Cellar/libunistring/1.1: 56 files, 5.0MB
==> Installing php dependency: libidn2
==> Pouring libidn2--2.3.4_1.arm64_monterey.bottle.tar.gz
🍺  /opt/homebrew/Cellar/libidn2/2.3.4_1: 79 files, 1MB
==> Installing php dependency: libnghttp2
==> Pouring libnghttp2--1.51.0.arm64_monterey.bottle.1.tar.gz
🍺  /opt/homebrew/Cellar/libnghttp2/1.51.0: 13 files, 738.0KB
==> Installing php dependency: libssh2
==> Pouring libssh2--1.10.0.arm64_monterey.bottle.tar.gz
🍺  /opt/homebrew/Cellar/libssh2/1.10.0: 184 files, 1MB
==> Installing php dependency: openldap
==> Pouring openldap--2.6.3.arm64_monterey.bottle.tar.gz
🍺  /opt/homebrew/Cellar/openldap/2.6.3: 340 files, 7.8MB
==> Installing php dependency: rtmpdump
==> Pouring rtmpdump--2.4+20151223_1.arm64_monterey.bottle.tar.gz
🍺  /opt/homebrew/Cellar/rtmpdump/2.4+20151223_1: 20 files, 646.4KB
==> Installing php dependency: lz4
==> Pouring lz4--1.9.4.arm64_monterey.bottle.tar.gz
🍺  /opt/homebrew/Cellar/lz4/1.9.4: 22 files, 681.5KB
==> Installing php dependency: xz
==> Pouring xz--5.4.0.arm64_monterey.bottle.tar.gz
🍺  /opt/homebrew/Cellar/xz/5.4.0: 95 files, 1.6MB
==> Installing php dependency: zstd
==> Pouring zstd--1.5.2.arm64_monterey.bottle.3.tar.gz
🍺  /opt/homebrew/Cellar/zstd/1.5.2: 31 files, 2.2MB
==> Installing php dependency: curl
==> Pouring curl--7.87.0.arm64_monterey.bottle.tar.gz
🍺  /opt/homebrew/Cellar/curl/7.87.0: 510 files, 4.3MB
==> Installing php dependency: libtool
==> Pouring libtool--2.4.7.arm64_monterey.bottle.tar.gz
🍺  /opt/homebrew/Cellar/libtool/2.4.7: 75 files, 3.8MB
==> Installing php dependency: unixodbc
==> Pouring unixodbc--2.3.11.arm64_monterey.bottle.tar.gz
🍺  /opt/homebrew/Cellar/unixodbc/2.3.11: 48 files, 2.3MB
==> Installing php dependency: freetds
==> Pouring freetds--1.3.16.arm64_monterey.bottle.tar.gz
🍺  /opt/homebrew/Cellar/freetds/1.3.16: 1,262 files, 14MB
==> Installing php dependency: libpng
==> Pouring libpng--1.6.39.arm64_monterey.bottle.tar.gz
🍺  /opt/homebrew/Cellar/libpng/1.6.39: 27 files, 1.3MB
==> Installing php dependency: freetype
==> Pouring freetype--2.12.1.arm64_monterey.bottle.tar.gz
🍺  /opt/homebrew/Cellar/freetype/2.12.1: 67 files, 2.3MB
==> Installing php dependency: fontconfig
==> Pouring fontconfig--2.14.1.arm64_monterey.bottle.tar.gz
==> Regenerating font cache, this may take a while
==> /opt/homebrew/Cellar/fontconfig/2.14.1/bin/fc-cache -frv
🍺  /opt/homebrew/Cellar/fontconfig/2.14.1: 88 files, 2.4MB
==> Installing php dependency: jpeg-turbo
==> Pouring jpeg-turbo--2.1.4.arm64_monterey.bottle.tar.gz
🍺  /opt/homebrew/Cellar/jpeg-turbo/2.1.4: 44 files, 2.5MB
==> Installing php dependency: giflib
==> Pouring giflib--5.2.1.arm64_monterey.bottle.tar.gz
🍺  /opt/homebrew/Cellar/giflib/5.2.1: 19 files, 540.7KB
==> Installing php dependency: highway
==> Pouring highway--1.0.2.arm64_monterey.bottle.tar.gz
🍺  /opt/homebrew/Cellar/highway/1.0.2: 61 files, 2.3MB
==> Installing php dependency: imath
==> Pouring imath--3.1.6.arm64_monterey.bottle.tar.gz
🍺  /opt/homebrew/Cellar/imath/3.1.6: 49 files, 931.4KB
==> Installing php dependency: openexr
==> Pouring openexr--3.1.5.arm64_monterey.bottle.tar.gz
🍺  /opt/homebrew/Cellar/openexr/3.1.5: 194 files, 6.0MB
==> Installing php dependency: libtiff
==> Pouring libtiff--4.4.0_1.arm64_monterey.bottle.1.tar.gz
🍺  /opt/homebrew/Cellar/libtiff/4.4.0_1: 249 files, 4.8MB
==> Installing php dependency: webp
==> Pouring webp--1.2.4.arm64_monterey.bottle.tar.gz
🍺  /opt/homebrew/Cellar/webp/1.2.4: 41 files, 2.2MB
==> Installing php dependency: jpeg-xl
==> Pouring jpeg-xl--0.7.0_1.arm64_monterey.bottle.tar.gz
🍺  /opt/homebrew/Cellar/jpeg-xl/0.7.0_1: 41 files, 9.9MB
==> Installing php dependency: libvmaf
==> Pouring libvmaf--2.3.1.arm64_monterey.bottle.tar.gz
🍺  /opt/homebrew/Cellar/libvmaf/2.3.1: 234 files, 7MB
==> Installing php dependency: aom
==> Pouring aom--3.5.0_1.arm64_monterey.bottle.tar.gz
🍺  /opt/homebrew/Cellar/aom/3.5.0_1: 23 files, 8.5MB
==> Installing php dependency: libavif
==> Pouring libavif--0.11.1.arm64_monterey.bottle.tar.gz
🍺  /opt/homebrew/Cellar/libavif/0.11.1: 19 files, 496.5KB
==> Installing php dependency: gd
==> Pouring gd--2.3.3_4.arm64_monterey.bottle.tar.gz
🍺  /opt/homebrew/Cellar/gd/2.3.3_4: 33 files, 1.5MB
==> Installing php dependency: gmp
==> Pouring gmp--6.2.1_1.arm64_monterey.bottle.tar.gz
🍺  /opt/homebrew/Cellar/gmp/6.2.1_1: 21 files, 3.2MB
==> Installing php dependency: icu4c
==> Pouring icu4c--71.1.arm64_monterey.bottle.tar.gz
🍺  /opt/homebrew/Cellar/icu4c/71.1: 262 files, 76.8MB
==> Installing php dependency: krb5
==> Pouring krb5--1.20.1.arm64_monterey.bottle.tar.gz
🍺  /opt/homebrew/Cellar/krb5/1.20.1: 162 files, 5.6MB
==> Installing php dependency: libpq
==> Pouring libpq--15.1.arm64_monterey.bottle.tar.gz
🍺  /opt/homebrew/Cellar/libpq/15.1: 2,367 files, 28.4MB
==> Installing php dependency: libsodium
==> Pouring libsodium--1.0.18_1.arm64_monterey.bottle.tar.gz
🍺  /opt/homebrew/Cellar/libsodium/1.0.18_1: 73 files, 779.8KB
==> Installing php dependency: libzip
==> Pouring libzip--1.9.2.arm64_monterey.bottle.tar.gz
🍺  /opt/homebrew/Cellar/libzip/1.9.2: 145 files, 851.7KB
==> Installing php dependency: oniguruma
==> Pouring oniguruma--6.9.8.arm64_monterey.bottle.tar.gz
🍺  /opt/homebrew/Cellar/oniguruma/6.9.8: 14 files, 1.4MB
==> Installing php dependency: pcre2
==> Pouring pcre2--10.42.arm64_monterey.bottle.tar.gz
🍺  /opt/homebrew/Cellar/pcre2/10.42: 230 files, 6.2MB
==> Installing php dependency: readline
==> Pouring readline--8.2.1.arm64_monterey.bottle.tar.gz
🍺  /opt/homebrew/Cellar/readline/8.2.1: 50 files, 1.7MB
==> Installing php dependency: sqlite
==> Pouring sqlite--3.40.1.arm64_monterey.bottle.tar.gz
🍺  /opt/homebrew/Cellar/sqlite/3.40.1: 11 files, 4.4MB
==> Installing php dependency: tidy-html5
==> Pouring tidy-html5--5.8.0.arm64_monterey.bottle.tar.gz
🍺  /opt/homebrew/Cellar/tidy-html5/5.8.0: 14 files, 3MB
==> Installing php
==> Pouring php--8.2.1.arm64_monterey.bottle.tar.gz
==> /opt/homebrew/Cellar/php/8.2.1/bin/pear config-set php_ini /opt/homebrew/etc
==> /opt/homebrew/Cellar/php/8.2.1/bin/pear config-set php_dir /opt/homebrew/sha
==> /opt/homebrew/Cellar/php/8.2.1/bin/pear config-set doc_dir /opt/homebrew/sha
==> /opt/homebrew/Cellar/php/8.2.1/bin/pear config-set ext_dir /opt/homebrew/lib
==> /opt/homebrew/Cellar/php/8.2.1/bin/pear config-set bin_dir /opt/homebrew/opt
==> /opt/homebrew/Cellar/php/8.2.1/bin/pear config-set data_dir /opt/homebrew/sh
==> /opt/homebrew/Cellar/php/8.2.1/bin/pear config-set cfg_dir /opt/homebrew/sha
==> /opt/homebrew/Cellar/php/8.2.1/bin/pear config-set www_dir /opt/homebrew/sha
==> /opt/homebrew/Cellar/php/8.2.1/bin/pear config-set man_dir /opt/homebrew/sha
==> /opt/homebrew/Cellar/php/8.2.1/bin/pear config-set test_dir /opt/homebrew/sh
==> /opt/homebrew/Cellar/php/8.2.1/bin/pear config-set php_bin /opt/homebrew/opt
==> /opt/homebrew/Cellar/php/8.2.1/bin/pear update-channels
==> Caveats
To enable PHP in Apache add the following to httpd.conf and restart Apache:
    LoadModule php_module /opt/homebrew/opt/php/lib/httpd/modules/libphp.so

    <FilesMatch \.php$>
        SetHandler application/x-httpd-php
    </FilesMatch>

Finally, check DirectoryIndex includes index.php
    DirectoryIndex index.php index.html

The php.ini and php-fpm.ini file can be found in:
    /opt/homebrew/etc/php/8.2/

To restart php after an upgrade:
  brew services restart php
Or, if you don't want/need a background service you can just run:
  /opt/homebrew/opt/php/sbin/php-fpm --nodaemonize
==> Summary
&#x1f37a;  /opt/homebrew/Cellar/php/8.2.1: 519 files, 83.3MB
==> Running `brew cleanup php`...
Disable this behaviour by setting HOMEBREW_NO_INSTALL_CLEANUP.
Hide these hints with HOMEBREW_NO_ENV_HINTS (see `man brew`).
==> Caveats
==> php
To enable PHP in Apache add the following to httpd.conf and restart Apache:
    LoadModule php_module /opt/homebrew/opt/php/lib/httpd/modules/libphp.so

    <FilesMatch \.php$>
        SetHandler application/x-httpd-php
    </FilesMatch>

Finally, check DirectoryIndex includes index.php
    DirectoryIndex index.php index.html

The php.ini and php-fpm.ini file can be found in:
    /opt/homebrew/etc/php/8.2/

To restart php after an upgrade:
  brew services restart php
Or, if you don't want/need a background service you can just run:
  /opt/homebrew/opt/php/sbin/php-fpm --nodaemonize
icon

以下のログまで表示されてエラーが表示されなければ、PATHを追加してください。

Or, if you don't want/need a background service you can just run:
  /opt/homebrew/opt/php/sbin/php-fpm --nodaemonize

スポンサードサーチ

PHPのPATHを通す

phpのPATHを通す

「.zshrc」ファイルにPHPのパスを追加します。

export PATH=/opt/homebrew/opt/php/bin:$PATH

PHPのインストールできるバージョンを確認

php -v

「php -v」でバージョンが返ってくれば、インストールとPATHの追加の完了です。

任意のバージョンでPHPをインストール

PHPのインストールできるバージョンを確認

brew search php

任意のPHPのバージョンをインストールしたい場合は、PHPのインストールできるバージョンを「brew search php」で検索して、
バージョンを指定してインストールするとができます。

brew install @php8.0

バージョンを指定してPHPをインストール

バージョンを指定してPHPをインストール

PHPのインストール可能なバージョンを検索

PHPのインストール可能なバージョンを検索

brew search php

PHPのバージョンを指定してインストール

PHPのバージョンを指定してインストール

php@8.0のようにPHPのバージョンを指定してインストールすることができます。

brew install php@8.0

バージョンを指定していない場合は最新版がインストールされます。

PHPのインストール済み確認

PHPのインストール済み確認

php -v

バージョンが返ってくればインストール済みです。

Homebrewのおすすめのパッケージ

Node.jsのインストール

homebrewでNode.jsをインストール

brew install nodebrew

Gitのインストール

homebrewでGitをインストール

brew install git

MySQLのインストール

homebrewでMySQLをインストール

brew install mysql

Composerのインストール

homebrewでComposerをインストール

brew install composer

まとめ

  • HomebrewがMacにインストールされているか確認する
  • Homebrewのインストールがまだなら、インストールを行う
  • Homebrewのパッケージを使って、PHPをインストールする

実装やエラーが解決できない場合

プログラミングの実装やエラーでどうしてもわからない場合はメンターに相談するのが一番です。

考えている、見えている範囲が狭くなり、解決から遠くに行って何時間も、何日も経っていることなんてよくある話です。

そういう時は聞ける先輩や、メンターに相談することが大事です。

僕にも相談可能なので気軽に相談してください。

Twitterからの連絡だと確実ですよ。

オンラインスクールやプログラミングスクールといったプログラミングを学べる方法もあるので、そちらもぜひ活用してもいいと思います。

Web開発で分からない時

オンライン完結型スクール DMM WEBCAMP PRO

アプリ開発で分からない時

プログラミング×稼げる副業スキルはテックキャンプ

プログラミングについて分からない時

【コエテコ様限定】※ご案内を受けた以外のメディアが使用しても成果は承認されません。
ミニマリスト_カミ

僕への個人でもメンターでも、スクールでもお好きな方を活用ください。

PHPPHP

Posted by kami