Installing the uploadprogress PECL extension on Leopard
The uploadprogress PECL extension is a PHP add-on that allows cool AJAX uploading like never before. Version 3 of Drupal's FileField module is designed to work best with uploadprogress enabled. As such, I found myself installing a PECL extension for the first time. No doubt, many other Drupal developers will soon be finding themselves in the same boat.
Unfortunately, for those of us on Mac OS X 10.5 (Leopard), installing uploadprogress ain't all smooth sailing. The problem is that the extension must be compiled from source in order to be installed; and on Leopard machines, which all run on a 64-bit processor, it must be compiled as a 64-bit binary. However, the gods of Mac (in their infinite wisdom) decided to include with Leopard (after Xcode is installed) a C compiler that still behaves in the old-school way, and that by default does its compilation in 32-bit mode. This is a right pain in the a$$, and if you're unfamiliar with the consequences of it, you'll likely see a message like this coming up in your Apache error log when you try to install uploadprogress and restart your server:
PHP Warning: PHP Startup: Unable to load dynamic library '/usr/local/php5/lib/php/extensions/no-debug-non-zts-20060613/uploadprogress.so' - (null) in Unknown on line 0
Hmmm… (null) in Unknown on line 0
. WTF is that supposed to mean? (You ask). Well, it means that the extension was compiled for the wrong environment; and when Leopard tries to execute it, a low-level error called a segmentation fault occurs. In short, it means that your binary is $#%&ed.
But fear not, Leopard PHP developers! Here are some instructions for how to install uploadprogress by compiling it as a 64-bit binary:
- Download and extract the latest tarball of the source code for uploadprogress.
- If using the Entropy PHP package (which I would highly recommend for all Leopard users), follow the advice from this forum thread (2nd comment, by Taracque), and change all your php binaries in
/usr/bin
to be symlinks to the proper versions in/usr/local/php5/bin
. cd
to the directory containing the extracted tarball that you downloaded, e.g.cd /download/uploadprogress-1.0.0
- Type:
sudo phpize
- Analogous to these instructions on SOAP, type:
MACOSX_DEPLOYMENT_TARGET=10.5 CFLAGS="-arch x86_64 -g -Os -pipe -no-cpp-precomp" CCFLAGS="-arch x86_64 -g -Os -pipe" CXXFLAGS="-arch x86_64 -g -Os -pipe" LDFLAGS="-arch x86_64 -bind_at_load" ./configure
This is the most important step, so make sure you type it in correctly! (If you get any sort of "permission denied" errors with this, then typesudo su
before running it, and typeexit
after running it). - Type:
sudo make
- Type:
sudo make install
- Add the line
extension=uploadprogress.so
to yourphp.ini
file (for Entropy users, this can be found at/usr/local/php5/lib/php.ini
) - Restart apache by typing:
sudo apachectl restart
If all is well, then a phpinfo()
check should output an uploadprogress
section, with a listing for the config variables uploadprogress.file.contents_template
, uploadprogress.file.filename_template
, and uploadprogress.get_contents
. Your Drupal status report should be happy, too. And, of course, FileField will totally rock.