以前安装opencart的时候倒是不需要mcrypt 这个库。但是新版本需要了。加上自己的 是mac环境。当时闲麻烦,就一直没装。这次下午就寻思给装上吧! 1.首先你要先安装xcode这个工具。不然没办法编译! xcode这个可以在苹果appstore下载。 2.安装 command line tools 打开xcode .->> Preferences 然后点击command line tools install 等下再完成安装就行了 也可以按照这个国外高人写的安装 https://github.com/kennethreitz/osx-gcc-installer 3.安装 Autoconf
cd /tmp 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 (需要输入你的密码) autoconf --version 老验证是否安装成功 fyhqytekiMacBook-Pro:tmp fyhqy$ autoconf --version autoconf (GNU Autoconf) 2.69 Copyright (C) 2012 Free Software Foundation, Inc. License GPLv3+/Autoconf: GNU GPL version 3 or later , This is free software: you are free to change and redistribute it. There is NO WARRANTY, to the extent permitted by law. Written by David J. MacKenzie and Akim Demaille.
4. 安装 libmcrypt 先检查机器的php版本。默认10.8安装的php版本是5.3.15.
fyhqytekiMacBook-Pro:tmp fyhqy$ php -v PHP 5.3.15 with Suhosin-Patch (cli) (built: Aug 24 2012 17:45:44) Copyright (c) 1997-2012 The PHP Group Zend Engine v2.3.0, Copyright (c) 1998-2012 Zend Technologies
下载对应版本的php版本包 5.3.15源码包 可以自己去页面下载。默认的托管在sina的sae上面
http://cn2.php.net/distributions/php-5.3.15.tar.gz
这个是5.3.15版本所有下载地址
http://php.net/get/php-5.3.15.tar.gz/from/a/mirror curl -O http://cn2.php.net/distributions/php-5.3.15.tar.gz tar zxvf php-5.3.15.tar.gz cd php-5.3.15/ext/mcrypt/ /usr/bin/phpize ./configure make sudo make install
编译的时候可能会提示这行
configure: error: mcrypt.h not found. Please reinstall libmcrypt.
这是因为没有安装mcrypt
curl -O http://sourceforge.net/projects/mcrypt/files/Libmcrypt/2.5.8/libmcrypt-2.5.8.tar.gz tar zxvf libmcrypt-2.5.8.tar.gz cd libmcrypt-2.5.8 ./configure --prefix=/usr/local/Cellar/mcrypt/2.5.8 --mandir=/usr/local/Cellar/mcrypt/2.5.8/shar make sudo make install
然后再执行上面步骤! 安装完成之后会提示
Installing shared extensions: /usr/lib/php/extensions/no-debug-non-zts-20090626/
然后修改php.ini。把扩展添加进去 php.ini 存在 /etc/php.ini
extension=mcrypt.so sudo apachectl restart
重启下apache。然后打开phpinfo(); 看是不是已经安装上了嗯!
在装mcrypt插件时报错,提示:mcrypt fatal error: 'php.h' file not found
按照下面的方法解决了
解决办法: sudo ln -s /Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX10.9.sdk/usr/include /usr/include
出自
http://blog.csdn.net/xfnjlove/article/details/18415441
这个问题是遇到多次了,不想再被坑了,
首先使mcrypt软件能够运行,然后安装php扩展模块,并在php.ini配置。
这里注意的是mcrypt软件依赖libmcrypt和mhash两个库,所以安装配置顺序从右至左
下载安装mcrypt
1.先去http://www.sourceforge.net下载Libmcrypt,mhash,mcrypt安装包 ,下面是我找到的链接
Libmcrypt(libmcrypt-2.5.8.tar.gz ):
http://sourceforge.net/project/showfiles.php?group_id=87941&package_id=91774&release_id=487459
mcrypt(mcrypt-2.6.8.tar.gz ):
http://sourceforge.net/project/showfiles.php?group_id=87941&package_id=91948&release_id=642101
mhash(mhash-0.9.9.9.tar.gz ):
http://sourceforge.net/project/showfiles.php?group_id=4286&package_id=4300&release_id=645636
2 .先安装Libmcrypt
#tar -zxvf libmcrypt-2.5.8.tar.gz
#cd libmcrypt-2.5.8
#./configure
#make
#make install
说明:libmcript默认安装在/usr/local
3.安装mhash
#tar -zxvf mhash-0.9.9.9.tar.gz
#cd mhash-0.9.9.9
#./configure
#make
#make install
4.安装mcrypt
#tar -zxvf mcrypt-2.6.8.tar.gz
#cd mcrypt-2.6.8
#LD_LIBRARY_PATH=/usr/local/lib/ ./configure -with-libmcrypt-prefix=/usr/local
#make
#make install
说明:由于在配置Mcrypt时,会找不到libmcrypt的链接库,导致无法编译,因为Libmcrypt的链接库在/usr/local/文件夹下。因些在配置mcrypt时要加入LD_LIBRARY_PATH=/usr/local导入键接库,
mac上有时会在make时有错误:rfc2440.c:26:20: error: malloc.h: No such file or directory,修改 rfc2440.c:#include <malloc.h>为#include <sys/malloc.h>, 重新make/make install即可,如在MAC10.9系统上有问题mcrypt fatal error: 'php.h' file not found,后面有详述
5.生成mcypt.so文件
- 下载并解压PHP源码文件php-5.3.4.tar.gz(一定是和系统的php的版本号一致)。Mac OS X 10.6.3中预装的PHP版本是5.3.4,所以需要下载这个版本。
- 在终端执行如下命令:
tar zxvf php-5.3.4.tar.gz
cd php-5.3.4/ext/mcrypt
phpize(如果./configure不能执行 先下载autoconf.tar.gz解压 在autoconf文件夹目录下执行./configure 然后make && make install 安装autoconf后就能在php文件夹下使用./configure配置php了 ,如这个装不上,后面还有详述)
./configure
make
sudo cp modules/mcrypt.so /usr/lib/php/extensions/no-debug-non-zts-20090626/ - 打开php.ini
sudo vi /etc/php.ini
在usr/etc/php.ini,中加入如下代码,并保存后退出,然后重启Apache(如没有复制php.ini.default,有时要修改写权限:chmod 777 php.ini )
extension=/usr/lib/php/extensions/no-debug-non-zts-20090626/mcrypt.so到这就结束了。注意:mac系统升级到10.9(mavericks)时安装php扩展问题解决
在装mcrypt插件时报错,提示:mcrypt fatal error: 'php.h' file not found,
然后又仔细操作了一次在输完phpize回车时就已经开始出错了,出错信息如下:
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:
解决办法:
sudo ln -s /Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX10.9.sdk/usr/include /usr/include
如autoconf安装不上,参考:安装这4个:1.curl -O http://mirrors.kernel.org/gnu/m4/m4-1.4.13.tar.gz
tar -xzvf m4-1.4.13.tar.gz
cd m4-1.4.13
./configure --prefix=/usr/local
make
sudo make install
cd ..
2.curl -O http://mirrors.kernel.org/gnu/autoconf/autoconf-2.65.tar.gz
tar -xzvf autoconf-2.65.tar.gz
cd autoconf-2.65
./configure --prefix=/usr/local # ironic, isn't it?
make
sudo make install
cd ..# here you might want to restart your terminal session, to ensure the new autoconf is picked up and used in the rest of the script3.curl -O http://mirrors.kernel.org/gnu/automake/automake-1.11.tar.gz
tar xzvf automake-1.11.tar.gz
cd automake-1.11
./configure --prefix=/usr/local
make
sudo make install
cd ..
4.curl -O http://mirrors.kernel.org/gnu/libtool/libtool-2.2.6b.tar.gz
tar xzvf libtool-2.2.6b.tar.gz
cd libtool-2.2.6b
./configure --prefix=/usr/local
make
sudo make install