Install PHP 7.4 in macOS Sierra with Homebrew
So, you’re still using macOS Sierra because of old mac hardware or whatever reason. You can still using Homebrew, while you will get the following warning:
Warning: You are using macOS 10.12. We (and Apple) do not provide support for this old version. You will encounter build failures with some formulae. Please create pull requests instead of asking for help on Homebrew's GitHub, Discourse, Twitter or IRC. You are responsible for resolving any issues you experience while you are running this old version.
Read above warning carefully before continue, as you will responsible yourself if experiencing issues.
First, if you are still want to try it, what you need to do is verify that you have latest Xcode 9.2
that support macOS Sierra:
$ /usr/bin/xcodebuild -version Xcode 9.2 Build version 9C40b
If you’re still using older version, you can first remove the Application/Xcode
directory and download manually (yes, manually) as you cannot update via App Store from the following URI:
https://developer.apple.com/services-account/download?path=/Developer_Tools/Xcode_9.2/Xcode_9.2.xip
That’s about 5GB file. After downloaded, you can extract to /Application
that will be about 10GB contents, if you’re using old mac hardware, it may take a while. After it extracted, you need to accept its license by run command:
$ sudo xcodebuild -license accept
If everything is correct, you can update and upgrade Homebrew with commands:
$ brew update $ brew upgrade
When done, you can verify that some “probably” dependencies needs install/update with run brew doctor until it only show 1 warning, which is outdated operating system:
$ brew doctor Please note that these warnings are just used to help the Homebrew maintainers with debugging if you file an issue. If everything you use Homebrew for is working fine: please don't worry or file an issue; just ignore this. Thanks! Warning: You are using macOS 10.12. We (and Apple) do not provide support for this old version. You will encounter build failures with some formulae. Please create pull requests instead of asking for help on Homebrew's GitHub, Discourse, Twitter or IRC. You are responsible for resolving any issues you experience while you are running this old version.
Now, we can follow to install php 7.4 for it at https://getgrav.org/blog/macos-catalina-apache-multiple-php-versions which the example is for macOS Catalina, that the steps can be used in macOS Sierra.
On PHP Installation
section steps, run install php 7.4 command via Homebrew:
$ brew install php@7.4
And that’s it, if everything is correct, now you have PHP 7.4.
Bonus
You can add Xdebug
extension with clone latest xdebug from its repository at https://github.com/xdebug/xdebug :
$ git clone https://github.com/xdebug/xdebug $ cd xdebug $ git checkout 2.8.1 $ phpize $ ./configure --enable-xdebug $ sudo make $ sudo make install
After it, add the following line to /usr/local/etc/php/7.4/php.ini
zend_extension="/usr/local/Cellar/php/7.4.0/pecl/20190902/xdebug.so"
zend_extension pointed to real location of xdebug.so installed above.
The alternative can be via pecl
command:
$ sudo pecl install xdebug
If everying correct, you will get PHP 7.4 with Xdebug 2.8.1 like the following php -v
command output:
2 comments