2015-10-01 238 views

回答

59

有一個更簡單的方法 - 無需禁用SIP或下載自己的副本:

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

這個OSX El Capitan(10.11.4)的作品,謝謝! – gillytech

+0

真棒謝謝! – Can

+0

酷!這應該標記爲答案 –

21

從這個鏈接:http://jason.pureconcepts.net/2012/10/install-pear-pecl-mac-os-x/有了這個說明,您不需要禁用「系統完整性保護」

The following instructions install PEAR and PECL on Mac OS X under /usr/local/. PECL is bundled with PEAR. So this is as simple as installing PEAR on Mac OS X. 

PEAR is PHP’s Package Repository and makes it easy to download and install PHP tools like PHPUnit and XDebug. I specifically recommend these two for every PHP developer. 

Download PEAR 
curl -O http://pear.php.net/go-pear.phar 
sudo php -d detect_unicode=0 go-pear.phar 

Configure and Install PEAR 
You should now be at a prompt to configure PEAR. 

Type 1 and press return. 
Enter: /usr/local/pear 

Type 4 and press return. 
Enter: /usr/local/bin 

Press return 

Verify PEAR. You should be able to type: 

pear version 

Eventually, if you use any extensions or applications from PEAR, you may need to update PHP’s include path. 
+2

謝謝謝謝謝謝 – kevando

28

你不應該二進制文件安裝到系統/usr,使用改爲。

可以使用自制軟件安裝pear

brew install php56 --with-pear 

注:如果上面的命令將無法正常工作,請確保您先添加水龍頭:brew tap homebrew/homebrew-php

注意:如果您已經有php56包,也可以輸入reinstall

,或者直接下載的Phar包:

curl -o /usr/local/bin/pear http://pear.php.net/go-pear.phar 
chmod +x /usr/local/bin/pear 

那麼你應該有peclpear二進制文件與你php

如果不是一起,通過重新鏈接它:

brew unlink php56 && brew link php56 --dry-run && brew link php56 

而且pecl你應該把它與php一起母雞通過brew install php56安裝。如果not,試圖將其手動鏈接:

ln -vs "$(find /usr/local/Cellar/php56 -name pecl -print -quit)" /usr/local/bin 
+1

@GregoryBell感謝您的好評。用'--with-pear'安裝PHP應該正確安裝pear(在/ usr/local/opt/php56/bin/pear'中)。然後'brew link php56'將它的二進制文件鏈接到'/ usr/local/bin/pear'。 – kenorb

+1

這必須是被接受的答案。 – sepehr

0

這個工作對我來說MacOS的塞拉利昂10.12.1的升級PHP,PEAR安裝和V8

brew tap homebrew/dupes 
brew tap homebrew/versions 
brew tap homebrew/homebrew-php 

phpversion="$(php -v | tail -r | tail -n 1 | cut -d " " -f 2 | cut -c 1,3)" 
brew unlink php$phpversion 

brew install php71 
brew install autoconf 

curl -O http://pear.php.net/go-pear.phar 
php -d detect_unicode=0 go-pear.phar 

echo -e "\nexport PATH=$HOME/pear/bin:$PATH \n" 

source ~/.bash_profile 

echo -e "\ninclude_path = '.:/Users/YOURUSERNAME/pear/share/pear/' \nextension=v8js.so \n" >> /usr/local/etc/php/7.1/php.ini 

git clone https://github.com/phpv8/v8js ~/tmp/v8js && cd $_ 
./configure CXXFLAGS="-Wno-c++11-narrowing" 
make 
make test 
make install 

sudo apachectl restart