【Mac OS X Yosemi…

来源:http://my.oschina.net/Twitter/blog/287543

来源:http://coolestguidesontheplanet .com/install-mcrypt-php-mac-osx-10-10-yosemite-development-server/
来源:http://my.oschina.net/Twitter/blog/287543

下载 libmcrypt 最新版本:libmcrypt-2.5.8.tar.gz

在终端执行以下命令,编译并安装它:

tar zxvf libmcrypt-2.5.8.tar.gz
cd libmcrypt-2.5.8
./configure
make
sudo make install

在终端执行以下命令,查看当前 Mac OS X 系统当前默认安装的 PHP 版本:

php -v

得到的结果可能是这样的:

PHP 5.5.14 (cli) (built: Sep 9 2014 19:09:25)
Copyright (c) 1997-2014 The PHP Group
Zend Engine v2.5.0, Copyright (c) 1998-2014 Zend Technologies
with Xdebug v2.2.3, Copyright (c) 2002-2013, by Derick Rethans

安装 Autoconf

Install autoconf – some more Terminal heavy lifting:

可以使用 brew install autoconf也可以使用如下命令
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

Mac OS X 10.10 Yosemite  默认安装的 PHP 版本是 5.5.14,下载对应版本的源码 php-5.5.14.tar.gz

在终端执行以下命令:

tar zxvf php-5.5.14.tar.gz
cd php-5.5.14/ext/mcrypt
phpize
./configure
make
sudo make install

安装完成后,执行以下命令,检查下 mcrypt 扩展是否能够正常加载:

php -m

如果遇上扩展编译版本和 PHP 编译版本不符的情况,会看到如下错误提示:

PHP Warning:  PHP Startup: mcrypt: Unable to initialize module
Module compiled with module API=20100525
PHP    compiled with module API=20121212
These options need to match
 in Unknown on line 0

执行执行 phpize 报错:
?
1
2
3
4
5
6
7
grep /usr/include/php/main/php .h: No such  file  or directory
grep /usr/include/php/Zend/zend_modules .h: No such  file  or directory
grep /usr/include/php/Zend/zend_extensions .h: No such  file  or directory
Configuring  for :
PHP Api Version:
Zend Module Api No:
Zend Extension Api No:

这个时候可能是因为 phpize 版本问题导致的,可以尝试解决办法:

sudo ln -s /Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX10.10.sdk/usr/include /usr/include
或者:sudo ln -s /Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX10.9.sdk/usr/include /usr/include
然后重新编译安装 libmcrypt 和 mcrypt 扩展,如果仍然报版本不一致的问题,可能是由于 phpize 生成 configure 文件缓存导致的,可以尝试:
cd php-5.5.14/ext/mcrypt
phpize –-clean

接着再从头到位安装一遍,应该就没啥问题了。


完成 mcrypt php 扩拓展安装

cd ../php-5.5.9/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

【Mac <wbr>OS <wbr>X <wbr>Yosemite】 <wbr>PHP <wbr>安装 <wbr>mcrypt <wbr>扩展拓展,phpize出错

【Mac <wbr>OS <wbr>X <wbr>Yosemite】 <wbr>PHP <wbr>安装 <wbr>mcrypt <wbr>扩展拓展,phpize出错

./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/

 

Enabling mcrypt.so  php Extension

Open /etc/php.ini and add the line below at the end

extension=mcrypt.so

If there is no php.ini file,  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

and add in the line:

extension=mcrypt.so

Restart Apache

sudo apachectl restart
  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值