How to install PHP, Pear, PECL, and APC with Homebrew on Mac OS X?
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 --with-mysqlI 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 305How can I fix this?
5 Answers
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:
- Reinstall PHP via:
brew install php. - Check
peclcommand 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.
pecl and pear are provided with Homebrew's version of PHP:
brew install php
pecl install apcuIf 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 installThe 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.
Below command should help
curl -s -O
sudo php install-pear-nozlib.phar -d /usr/local/lib/php -b /usr/local/bin 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.
You do not need install apc.
Just add
apc.enabled=on
apc.shm_size=64M
apc.enable_cli=onto your php.ini and make sure that your apcu is ok.