关于mac 10.11 EI Capitan 没有安装mcryp
因为我一直是使用的mac工作环境,MAMP PRO 3.5,是我使用的mac下最方便的php集成环境,但是今天安装laravel时候出现了一些问题,因为laravel需要composer进行install,需要mcrypt环境扩展,总是提示没有安装mcrypt扩展。
查看MAMP PRO环境phpinfo() 发现已经安装过
但是就是提示不成功,没有安装扩展,然后又检查了一遍composer,也没有问题
突然想起来mac系统自带的php环境。于是直接php-v一下 输出
果然,于是在网上找到了这一篇帖子
https://coolestguidesontheplanet.com/install-mcrypt-for-php-on-mac-osx-10-10-yosemite-for-a-development-server/
这里我也大概的说一下使用方式
打开命令行后首先安装Command line tools
xcode-select --install
完成后建立一个文件夹,下载所需要的libmcrypt以及php更新,具体地址Getlibmcrypt 2.5.8from Sourceforge,php的话Get thephpcode in atar.gz or .bz2format-
教程上说(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…