Install PHP on MacOS
Step 1. Install Homebrew
Install Homebrew, if it is not already installed.
- This will take a couple of minutes.
- Follow any steps that it recommends afterward.
Step 2. Install PHP 8.1
Use Homebrew to install PHP.
brew install php@8.1
- Note: If it gets stuck, just hit Enter to flush the output.
Step 3. Install Caches
This step is optional, but recommended for maximum performance.
1. Install APCu
pecl install apcu
2. Update php.ini
Find the location of your php.ini file.
php -i | grep "Loaded Configuration File"
Add the following entries to the bottom of your php.ini file.
[opcache] opcache.enable=1 opcache.enable_cli=1 [apcu] apc.enabled=1 apc.shm_size=32M apc.ttl=7200 apc.enable_cli=1 apc.serializer=php
Step 4. Check It
Check the PHP version.
$ php -v
You will see something like this:
PHP 8.1.7 (cli) (built: Jun 9 2022 14:08:46) (NTS) Copyright (c) The PHP Group Zend Engine v4.1.7, Copyright (c) Zend Technologies with Zend OPcache v8.1.7, Copyright (c), by Zend Technologies
Great!
Back to install THT: