📜  安装 php 5.6 mac - PHP (1)

📅  最后修改于: 2023-12-03 15:25:06.678000             🧑  作者: Mango

安装 PHP 5.6 on Mac

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.

Prerequisites

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)"
Install PHP 5.6

Open the terminal and run:

brew tap exolnet/homebrew-deprecated
brew install php@5.6

This will install PHP 5.6 on your Mac.

Switch to PHP 5.6

By default, your Mac still uses the system-provided PHP version. We need to switch to PHP 5.6.

Update the PATH

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.

Test PHP 5.6

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.

Conclusion

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.