且构网

分享程序员开发的那些事...
且构网 - 分享程序员编程开发的那些事

Plugging mcrypt into PHP, on Mac OS X Snow Leopard 10.6.1[转]

更新时间:2022-09-21 13:11:07

First mcrypt on Leopard, and now we ready for the winter cat. Additionally, special thanks goes out in advance to commenter Yvan Barthelemy (a.k.a. ybart) for cluing me in here. The procedure is almost exactly like the previous…almost. So pay attention.

The following instructions cater to those who a) are developing on OS X Snow Leopard 10.6.1, b) need the capabilities provided by mcrypt during their PHP development, and c) do not want to completely recompile PHP to get there. You’ll get mcrypt loading dynamically for use in PHP with this method.

First, you are going to need a few things…

1) libmcrypt-2.5.8, which you can pick up here; NOTE: make sure to get libmcrypt and not mcrypt.

2) PHP 5.3.0 source, which you grab hereADDITIONAL NOTE: You may have already updated your OS X beyond 10.6.1, and PHP may have been updated along with it. In this case, use phpinfo() to check your version of PHP, and then download the PHP source for that version. Thanks to commenter Blair for suggesting this note;

and

3) Xcode 3.2 tools, which you can pick up here (Apple Developer Connection membership required).

Next, create a directory at root called ‘SourceCache’ and dump the files from #1 and #2 in there and unwrap.

Move to the libmcrypt-2.5.8 directory, and punch in this…

MACOSX_DEPLOYMENT_TARGET=10.6 CFLAGS='-O3 -fno-common -arch i386 -arch x86_64' LDFLAGS='-O3 -arch i386 -arch x86_64' CXXFLAGS='-O3 -fno-common -arch i386 -arch x86_64' ./configure --disable-dependency-tracking

and then…

make -j6

and finally…

sudo make install

libmcrypt is ready – now for the PHP extension…

Move back to /SourceCache, then down to php-5.3.0/ext/mcrypt – type…

/usr/bin/phpize (phpize should be in /usr/bin – if not go find it and change the command as appropriate)

Then configure as follows…

MACOSX_DEPLOYMENT_TARGET=10.6 CFLAGS='-O3 -fno-common -arch i386 -arch x86_64' LDFLAGS='-O3 -arch i386 -arch x86_64' CXXFLAGS='-O3 -fno-common -arch i386 -arch x86_64' ./configure --with-php-config=/Developer/SDKs/MacOSX10.6.sdk/usr/bin/php-config

Again make -j6 then sudo make install

Make sure you have php.ini in the /etc directory (it will probably be php.ini.default to start, particularly if you’ve just done the Snow Leopard upgrade, so rename it). Ensure that enable_dl = On but do not remove the ; from in front of ;extension_dir = "./". Add one line to the .ini file in the Dynamic Extensions section… extension=mcrypt.so

Restart Apache – you should be all set (again), according to phpinfo():

Plugging mcrypt into PHP, on Mac OS X Snow Leopard 10.6.1[转]

BIG NOTE: As the substantive content of this guide has aged a number of new releases have come out, including but not limited to patches for Snow Leopard. As a result, PHP versions have changed, XCode has been updated, and more. If you come across quirks during your attempts to get mcrypt working, please read the comments before detailing your problem, as many of those issues have been solved. Finally, thanks go out to all of the folks who have contributed – it is greatly appreciated by all!

 

from: http://michaelgracie.com/2009/09/23/plugging-mcrypt-into-php-on-mac-os-x-snow-leopard-10.6.1/ 

欢迎加群互相学习,共同进步。QQ群:iOS: 58099570 | Android: 572064792 | Nodejs:329118122 做人要厚道,转载请注明出处!



















本文转自张昺华-sky博客园博客,原文链接:http://www.cnblogs.com/sunshine-anycall/archive/2010/11/08/1872239.html,如需转载请自行联系原作者