9

I'm trying to install APC for PHP 5.3 in the easiest way possible. I love Homebrew so I started down that route. I was able to install PHP 5.3.6 with this command:

brew install https://github.com/adamv/homebrew-alt/raw/master/duplicates/php.rb --with-mysql

I think this is supposed to install PHP, Pear, and PECL. It seems to install these just fine.

Now when I try to install APC:

$ pecl install apc
downloading APC-3.1.9.tgz ...
Starting to download APC-3.1.9.tgz (155,540 bytes)
.................................done: 155,540 bytes

Warning: require_once(Archive/Tar.php): failed to open stream: No such file or directory in PackageFile.php on line 305

Warning: require_once(Archive/Tar.php): failed to open stream: No such file or directory in /usr/local/Cellar/php/5.3.6/lib/php/PEAR/PackageFile.php on line 305

Fatal error: require_once(): Failed opening required 'Archive/Tar.php' (include_path='/usr/local/Cellar/php/5.3.6/lib/php') in /usr/local/Cellar/php/5.3.6/lib/php/PEAR/PackageFile.php on line 305

How can I fix this?

6

Now homebrew-php has been migrated to homebrew-core and by default, PECL should be installed along with your PHP.

Here are the suggested steps:

  1. Reinstall PHP via: brew install php.
  2. Check pecl command by: which -a pecl.

To see which files were installed, see: brew list php.

To install PHP extensions, you need to use PECL as a recommended way.

With the migration to Homebrew-core the php formula has stopped taking over the role of PECL. Installing xdebug can (and should) be done through PECL. Source: GH-26007

For example: pecl install apc or pecl install xdebug.

If you've got some problem installing the extension, you need to report it to its maintainer. Check PECL website for more details.

1

pecl and pear are provided with Homebrew's version of PHP:

brew install php
pecl install apcu

If you're weary that pecl and pear are provided by php, try this:

ls -al $(which pecl)
ls -al $(which pear)

Both locations should symlink to Cellar/php/...

Note, macOS provides a php version which is generally behind that of Homebrew. To make sure you're running the Homebrew version, prefix your php commands with $(brew --prefix php)/bin.

Example for Composer:

$(brew --prefix php)/bin/php composer.phar install

The reason this is important is because common extensions -- such as ext-intl and ext-gettext are provided automatically and will fix these automatically.

Notice, for php-fpm, use brew reinstall php --with-fpm. The php-fpm path will be... $(brew --prefix php)/sbin/php-fpm.

1

Below command should help

curl -s -O https://pear.php.net/install-pear-nozlib.phar

sudo php install-pear-nozlib.phar -d /usr/local/lib/php -b /usr/local/bin
0

Homebrew PHP's GitHub site says that:

Pear is no longer compiled by default, instead you need to install php with the --with-pear option, such as: brew install php56 --with-pear.

So, to make PHP 7.0 work, use the following installation command:

brew install php70 --with-pear

You can of course use this with other versions of PHP, too.

0

You do not need install apc.
Just add

apc.enabled=on
apc.shm_size=64M
apc.enable_cli=on

to your php.ini and make sure that your apcu is ok.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.