PHPBrew and Apache



I’ve installed and configured PHPBrew to get PHP7 installed in my workspace. The only problem is that it only seems to be available in the CLI but not to Apache, restarting Apache doesn’t help and it still reports PHP 5+.

I’ve seen some posts elsewhere about installing with the apxs2 variant but that fails with “Exception: apxs binary is not executable”.

I’ve checked my previously set up workspaces as I’ve installed PHP7 the same way but they also have the same issue, PHP7 is available to the CLI only and not Apache.

Any ideas?


I’m guessing you had a look at this thread:

Try executing that command with sudo, so:

sudo phpbrew install 5.4.22 +apxs2=/usr/bin/apxs2


Yes, I saw that but when I try it I get the following:

$ sudo phpbrew install 7.0.3 +apxs2=/usr/bin/apxs2
===> phpbrew will now build 7.0.3
===> Loading and resolving variants…
Checking distribution checksum…
Checksum matched: 702e9b8e2cb704fdd50137e39f53f50b
===> Distribution file was successfully extracted, skipping…
Found existing Makefile, running make clean to ensure everything will be rebuilt.
You can append --no-clean option after the install command if you don’t want to rebuild.
===> Running make clean: make -C /home/ubuntu/.phpbrew/build/php-7.0.3 --quiet clean
Exception: apxs binary is not executable: /usr/bin/apxs2

0) PhpBrew\Tasks\Apxs2CheckTask->check(PhpBrew\Build, GetOptionKit\OptionResult)
1) PhpBrew\Tasks\ConfigureTask->run(PhpBrew\Build, ['--disable-all', '--enable-phar', '--enable-session', '--enable-short-tags', '--enable-tokenizer', '--with-pcre-regex', '--with-zlib=/usr', '--with-libdir=lib/x86_64-linux-gnu', '--with-apxs2=/usr/bin/apxs2', '--enable-dom', '--enable-libxml', '--enable-simplexml', '--enable-xml', '--enable-xmlreader', '--enable-xmlwriter', '--with-xsl', '--with-libxml-dir=/usr'])
2) PhpBrew\Command\InstallCommand->execute('7.0.3', '+apxs2=/usr/bin/apxs2')
3) call_user_func_array([PhpBrew\Command\InstallCommand, 'execute'], ['7.0.3', '+apxs2=/usr/bin/apxs2'])
4) CLIFramework\CommandBase->executeWrapper(['7.0.3', '+apxs2=/usr/bin/apxs2'])
5) CLIFramework\Application->run(['/usr/local/bin/phpbrew', 'install', '7.0.3', '+apxs2=/usr/bin/apxs2'])
6) CLIFramework\Application->runWithTry(['/usr/local/bin/phpbrew', 'install', '7.0.3', '+apxs2=/usr/bin/apxs2'])
7) require('phar:///usr/local/bin/phpbrew/scripts/phpbrew-emb.php')


Can you try installing this alternate way and see if that works?

Could even try from a fresh workspace to see if that makes a difference.


In case someone else comes along I was able to get past this by running

$ sudo apt-get -y install apache2-dev

But then I had to change the permissions on the following directories which is NOT recommended on a production environment.

$ sudo chmod -R oga+rw /usr/lib/apache2/modules $ sudo chmod -R oga+rw /etc/apache2

After all these changes I was able to run (would assume php7 works the same)

phpbrew install 5.6 +default +mysql +gd +apxs2

I had no trouble with php5 loading but if using php7 you might have to follow the already mentioned post Tell apache to use a specific php version installed using phpbrew over at Stackoverflow.