📅  最后修改于: 2023-12-03 15:25:06.678000             🧑  作者: Mango
PHP 5.6 is an older version of PHP but still widely used in some legacy projects. Here, we will go through the steps to install PHP 5.6 on a Mac.
Before we start, make sure you have Homebrew installed. If you don't, open the terminal on your Mac and run:
/bin/bash -c "$(curl -fsSL https://raw.githubusercontent.com/Homebrew/install/HEAD/install.sh)"
Open the terminal and run:
brew tap exolnet/homebrew-deprecated
brew install php@5.6
This will install PHP 5.6 on your Mac.
By default, your Mac still uses the system-provided PHP version. We need to switch to PHP 5.6.
Open the .bash_profile
file in your home directory:
nano ~/.bash_profile
And add the following line:
export PATH="/usr/local/opt/php@5.6/bin:$PATH"
Save and exit the file.
Close and reopen the terminal to apply the changes to the PATH. Then, run:
php -v
This should show that PHP 5.6 is now the active version.
Now you know how to install and switch to PHP 5.6 on a Mac. Keep in mind that PHP 5.6 is no longer supported and has security vulnerabilities. Upgrade to a newer version if possible.