Garry Garry - 9 months ago 386
PHP Question

Unable to install PHP 7 with Homebrew on macOS Sierra

I'm trying to setup Laravel's Valet which, as a dependency, requires PHP 7. When I try to install PHP 7 with Homebrew I get the following error:

Configuring SAPI modules
checking for Apache 2.0 handler-module support via DSO through APXS...

Sorry, I cannot run apxs. Possible reasons follow:

1. Perl is not installed
2. apxs was not found. Try to pass the path using --with-apxs2=/path/to/apxs
3. Apache was not built using --enable-so (the apxs usage page is displayed)

The output of /usr/sbin/apxs follows:
apxs:Error: /Applications/ not found!.

configure: error: Aborting

If reporting this issue please do so at (not Homebrew/brew):

These open issues may also help:
php70-intl not found
php70-opcache install issue
Problem installing php70-mcrypt, php70-opcache, php70-xdebug on El Capitan
Add php70-zmq formula
Problem installing homebrew/php/php70-imagick
Install PHP70: Incompatible library version
brew install php70-redis
Allow --enable-redis-igbinary for php70-redis
Add head formula for php70-uploadprogress

This is on a fresh install of macOS Sierra (actual release, not a beta) with a fresh install of Homebrew (updated). I have installed, ran and agreed to the Xcode licensing agreement.

I have no idea what these errors mean or how to fix them. Can anyone offer any help?



Right I've figured it out. I'm posting the steps to successfully install the require components below in case anybody else stumbles upon this issue:

1). make sure Homebrew is up to date:

brew update

2). Fix the PHP 7 error by making sure Xcode is installed and then typing the following into the Terminal:

brew install apr apr-util
sudo mkdir -p /Applications/
sudo ln -s /usr/local/opt/apr/bin/apr-1-config /Applications/
sudo ln -s /usr/local/opt/apr-util/bin/apu-1-config /Applications/

3). Run the following command (otherwise the PHP installation will complain about missing libz):

xcode-select --install

4). You can now install PHP 7 with Homebrew:

brew install homebrew/php/php70