How to install PHP APC in OS X

I assume you already have PEAR/PECL available. I am using the Mac OS X PHP environment that is provided by Apple’s XCode but it shouldn’t matter how you get your PHP. First you need to update your channels:

[code lang=”bash”]kahwee:~ kahwee$ sudo pear update-channels
Updating channel “doc.php.net”
Channel “doc.php.net” is up to date
Updating channel “pear.php.net”
Channel “pear.php.net” is up to date
Updating channel “pecl.php.net”
Channel “pecl.php.net” is up to date[/code]

Continue reading “How to install PHP APC in OS X”

Cambridge refuses censorship on chip-and-PIN vulnerabilities

According to BoingBoing, the UK banking trade association wrote to Cambridge to have a student’s master’s thesis censored as it documented a well-known flaw in the chip-and-PIN system, Cambridge University’s Ross Anderson replied with the following:

Second, you seem to think that we might censor a student’s thesis, which is lawful and already in the public domain, simply because a powerful interest finds it inconvenient. This shows a deep misconception of what universities are and how we work. Cambridge is the University of Erasmus, of Newton, and of Darwin; censoring writings that offend the powerful is offensive to our deepest values. Thus even though the decision to put the thesis online was Omar’s, we have no choice but to back him. That would hold even if we did not agree with the material! Accordingly I have authorised the thesis to be issued as a Computer Laboratory Technical Report. This will make it easier for people to find and to cite, and will ensure that its presence on our web site is permanent….

You complain that our work may undermine public confidence in the payments system. What will support public confidence in the payments system is evidence that the banks are frank and honest in admitting its weaknesses when they are exposed, and diligent in effecting the necessary remedies. Your letter shows that, instead, your member banks do their lamentable best to deprecate the work of those outside their cosy club, and indeed to censor it. [Source: Cambridge]

The reply is full of win, academic world scores one.

HTC Desire HD update coming

From Twitter:

European Desire HD / Desire Z users – look out for an update rolling out from today that will make your mobile experience even better. [@htc]

But it isn’t a Gingerbread update:

To clarify, the Desire Z/Desire HD update is a maintenance build based on all your feedback. Gingerbread is not a part of this update. [@htc]

I have yet to receive the update though. I’m using SingTel from Singapore. HTC has not revealed much on what the update contains.

SingTel AMPed SMSes are really annoying

I am not interested at all. No unsubscribe option. Do I have to call SingTel specially to request for a delist? I have received numerous SMSes on that. Oh and the customized ringtones? Oh god they are annoying. Why did SingTel even think I would appreciate them changing to some song I never heard before? I just want the lousy default dial tone that is really really boring because it tells so much of my personality. Thank you.

Just got an Android

I finally gotten a HTC Desire HD as some may know. What I like about it is really the browser.

Not surprisingly the Android platform has applications that are — how shall I put it — less exciting. Compared to the Apple iPhone it has a lesser application store. Notable applications on the Android includes Gmail, Twitter and Maps.

Google did Maps very well and give it away for free. It’s the app that I am most willing to pay for but can’t.

What’s lacking in the HTC Desire HD for me is a Japanese keyboard and battery. The Desire HD can last me for a day, sometimes less all thanks to the huge screen. Sense UI is a beauty to look at but I wish users can easily uninstall applications such as Peeps and Teeter. The keyboard height is a little too tall for my liking too.

Overall I like the HTC Desire HD especially the small little features to discover of the user’s hand is holding the device and then reducing the ringtone volume. That’s a neat touch and it delights me that the phone is design with much consideration of how the user can possibly interact with the phone less apparently.

How to compile PHP mcrypt extension in OS X

I have just switched from using MacPorts to using Homebrew and I decide to use what’s provided by Apple Mac OS X as much as possible. This means that I’ll be using the Apache and PHP 5.3.3 that is provided as part of Apple’s XCode. Unfortunately, there are some extensions that are just not available as part of Apple’s PHP package. One of them would be mcrypt.

One of the ways to get mcrypt in would be to recompile the entire PHP source code. That method works but I would prefer using Apple’s stock PHP and just load a few additional modules. The following instructions documents how I managed to install PHP mcrypt by compiling the extension. I hope it can help in your work too.

Firstly I got libmcrypt from Homebrew. To do that:

[code lang=”bash”]brew install libmcrypt[/code]

libmcrypt is needed for PHP mcrypt. You’ll also need to download a copy of PHP source code. The PHP that comes with my OS X is 5.3.3:

[code lang=”bash”]kahwee:~ kahwee$ which php
/usr/bin/php
kahwee:~ kahwee$ php -v
PHP 5.3.3 (cli) (built: Aug 22 2010 19:41:55)
Copyright (c) 1997-2010 The PHP Group
Zend Engine v2.3.0, Copyright (c) 1998-2010 Zend Technologies
kahwee:~ kahwee$ [/code]

So I downloaded and extracted my copy to: /Users/kahwee/Packages/php-5.3.3

All the PHP extensions are located here: /Users/kahwee/Packages/php-5.3.3/ext. I am going to require mcrypt so let’s get the extension (.so) file.

Current I’m in /Users/kahwee/Packages/php-5.3.3/ext/mcrypt/module/mcrypt. Let’s start by running phpize, it’s a utility to prepare for the build environment.

[code lang=”bash”]kahwee:mcrypt kahwee$ phpize
Configuring for:
PHP Api Version: 20090626
Zend Module Api No: 20090626
Zend Extension Api No: 220090626[/code]

Run aclocal, then ./configure:

[code lang=”bash”]kahwee:mcrypt kahwee$ aclocal
kahwee:mcrypt kahwee$ ./configure
checking for grep that handles long lines and -e… /usr/bin/grep
checking for egrep… /usr/bin/grep -E
checking for a sed that does not truncate output… /usr/bin/sed
……[/code]

Finally we can make the extension:

[code lang=”bash”]kahwee:mcrypt kahwee$ make
/bin/sh /Users/kahwee/Packages/php-5.3.3/ext/mcrypt/libtool –mode=compile cc -I. -I/Users/kahwee/Packages/php-5.3.3/ext/mcrypt -DPHP_ATOM_INC -I/Users/kahwee/Packages/php-5.3.3/ext/mcrypt/include -I/Users/kahwee/Packages/php-5.3.3/ext/mcrypt/main -I/Users/kahwee/Packages/php-5.3.3/ext/mcrypt -I/usr/include/php -I/usr/include/php/main -I/usr/include/php/TSRM -I/usr/include/php/Zend -I/usr/include/php/ext -I/usr/include/php/ext/date/lib -I/usr/local/include -DHAVE_CONFIG_H -g -O2 -c /Users/kahwee/Packages/php-5.3.3/ext/mcrypt/mcrypt.c -o mcrypt.lo
mkdir .libs

……

Libraries have been installed in:
/Users/kahwee/Packages/php-5.3.3/ext/mcrypt/modules

If you ever happen to want to link against installed libraries
in a given directory, LIBDIR, you must either use libtool, and
specify the full pathname of the library, or use the -LLIBDIR'
flag during linking and do at least one of the following:
- add LIBDIR to the
DYLD_LIBRARY_PATH’ environment variable
during execution

See any operating system documentation about shared libraries for

more information, such as the ld(1) and ld.so(8) manual pages.

Build complete.
Don’t forget to run ‘make test’.

[/code]

Now you can find your extension in the module folder. For my case, it is found in /Users/kahwee/Packages/php-5.3.3/ext/mcrypt/modules/mcrypt.so