PHP 8.1.15 Released!


macOS 下有几个预编译和打包的 PHP 版本。可以通过它使用标准的配置的 PHP,但是若需要不同的功能集(比如一个安全服务器,或者一个不同的数据库驱动程序),可能需要自己编译 PHP 和/或 web 服务器。如果不熟悉如何自己编译软件,可以试着找一下包含自己所需功能的 PHP 预编译版本。

在 macOS 上安装 PHP 最简便的方式是用 homebrew:

  1. 安装 homebrew:参考 » 上的说明

  2. brew install php

下面可选资源提供了在 macOS 上易于安装的软件包和预编译的二进制 PHP。

add a note

User Contributed Notes 5 notes

Chris Varen
3 months ago
@marc_cole Note that phpbrew ( requires you already have some version of PHP on your system. This is because phpbrew itself is written in php. And recent versions of macOS no longer come with php included.

So phpbrew isn't really an alternative since you still need to use homebrew or something else to install php in the first place.
1 year ago
Granted, this is not a "package", but I prefer to use phpbrew, as it allows me to install as many versions of PHP as I want for testing or whatever.
1 year ago
You can use Laravel valet, what is included PHP, Nginx, DNSMasq and a lot of things for easy developing. (
saintalifrh at disroot dot org
1 year ago
Valet requires macOS and Homebrew. Before installation, you should make sure that no other programs such as Apache or Nginx are binding to your local machine's port 80.

you need to install brew anyway
5 months ago
remember after step 1 installing homebrew to run these two commands, one at a time in the terminal window - where xxxxx is the name of the current profile - (who you are logged in as)

echo 'eval "$(/opt/homebrew/bin/brew shellenv)"' >> /Users/xxxxx/.zprofile

eval "$(/opt/homebrew/bin/brew shellenv)"

Only then will you be able to run step 2 brew...
To Top