因?yàn)槲乙恢笔鞘褂玫膍ac工作環(huán)境,MAMP PRO 3.5雷滋,是我使用的mac下最方便的php集成環(huán)境不撑,但是今天安裝laravel時(shí)候出現(xiàn)了一些問(wèn)題文兢,因?yàn)閘aravel需要composer進(jìn)行install,需要mcrypt環(huán)境擴(kuò)展燎孟,總是提示沒(méi)有安裝mcrypt擴(kuò)展禽作。
查看MAMP PRO環(huán)境phpinfo() 發(fā)現(xiàn)已經(jīng)安裝過(guò)
但是就是提示不成功,沒(méi)有安裝擴(kuò)展揩页,然后又檢查了一遍composer旷偿,也沒(méi)有問(wèn)題
突然想起來(lái)mac系統(tǒng)自帶的php環(huán)境。于是直接php-v一下 輸出
果然爆侣,于是在網(wǎng)上找到了這一篇帖子
https://coolestguidesontheplanet.com/install-mcrypt-for-php-on-mac-osx-10-10-yosemite-for-a-development-server/
這里我也大概的說(shuō)一下使用方式
打開(kāi)命令行后首先安裝Command line tools
xcode-select --install
完成后建立一個(gè)文件夾萍程,下載所需要的libmcrypt以及php更新,具體地址Getlibmcrypt 2.5.8from Sourceforge,php的話Get thephpcode in atar.gz or .bz2format-
教程上說(shuō)(version 5.5.27 is the one that currently ships with OSX 10.11) 所以就下載了5.5.27
Move both of these files that you downloaded into your working directory –mcryptin this instance, and go back to Terminal
cd ~/mcrypt
Expand both files via the command line or just double click them in the Finder:
tar -zxvf libmcrypt-2.5.8.tar.gz
tar -zxvf?php-5.5.27.tar.gz
Remove the compressed archives
rm *.gz
Any errors on the command line including C++ and g++ mostly are due to the command line tools missing.
Configuring libmcrypt
Change directory into libmcrypt
cd?libmcrypt-2.5.8
Libmcrypt needs to be configured, enter
./configure
make
sudo make install
With the libmcrypt configured and libraries now installed, time for to make the mcrypt extension.
Install Autoconf
Installautoconf– some more Terminal heavy lifting:
cd ~/mcrypt
curl -O http://ftp.gnu.org/gnu/autoconf/autoconf-latest.tar.gz
tar xvfz autoconf-latest.tar.gz
cd autoconf-2.69/
./configure
make
sudo make install
Compile mcrypt php Extension
cd ../php-5.5.27/ext/mcrypt/
/usr/bin/phpize
Output should be similar to:
Configuring for:
PHP Api Version: 20121113
Zend Module Api No: 20121212
Zend Extension Api No: 220121212
./configure
make
sudo make install
The result of this should be similar to:
Installing shared extensions: ?/usr/lib/php/extensions/no-debug-non-zts-20121212/
If you got an error like below then you need to disableSIP.
cp:/usr/lib/php/extensions/no-debug-non-zts-20121212/#INST@17000#: Operation not permitted
Enabling mcrypt.so ?php Extension
Open/etc/php.iniand add the line below at the end
extension=mcrypt.so
If there is nophp.inifile, ?then you need to make one from php.ini.default?in the same location like so:
sudo cp /etc/php.ini.default /etc/php.ini
And allow write capability
sudo chmod u+w ?/etc/php.ini
Then add the line as above in your favourite text editor:
sudo nano /etc/php.ini
or
sudo vi /etc/php.ini
make sure dynamic extensions are set to on…
extension_dl = On
and add in the line:
extension=mcrypt.so
Restart Apache
sudo apachectl restart
That’s it, create a php page with the functionphpinfo();to see if it loaded correctly.
If it didn’t load you may need to declare the extensions directory in /etc/php.ini
extension_dir = "/usr/lib/php/extensions/no-debug-non-zts-20100525/"
正在上傳...取消重新上傳
Hopefully it wasn’t too much of a nightmare…