標籤:style blog http color io os ar 使用 for
以前安裝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 /tmpcurl -O http://ftp.gnu.org/gnu/autoconf/autoconf-latest.tar.gztar xvfz autoconf-latest.tar.gzcd autoconf-2.69/./configuremakesudo make install(需要輸入你的密碼)autoconf --version 老驗證是否安裝成功fyhqytekiMacBook-Pro:tmp fyhqy$ autoconf --versionautoconf (GNU Autoconf) 2.69Copyright (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 -vPHP 5.3.15 with Suhosin-Patch (cli) (built: Aug 24 2012 17:45:44) Copyright (c) 1997-2012 The PHP GroupZend 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/mirrorcurl -O http://cn2.php.net/distributions/php-5.3.15.tar.gztar zxvf php-5.3.15.tar.gzcd php-5.3.15/ext/mcrypt//usr/bin/phpize./configuremakesudo 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.gztar zxvf libmcrypt-2.5.8.tar.gzcd libmcrypt-2.5.8 ./configure --prefix=/usr/local/Cellar/mcrypt/2.5.8 --mandir=/usr/local/Cellar/mcrypt/2.5.8/sharmake sudo make install
然後再執行上面步驟! 安裝完成之後會提示
Installing shared extensions: /usr/lib/php/extensions/no-debug-non-zts-20090626/
然後修改php.ini。把擴充添加進去 php.ini 存在 /etc/php.ini
extension=mcrypt.sosudo 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安裝不上,參考:http://www.mattvsworld.com/blog/2010/02/install-the-latest-autoconf-and-automake-on-mac-os-10-6/安裝這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 script
3.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
<親測好使>mac os 安裝mcrypt擴充