How to enable PECL uploadprogress extention in MAMP
26.07.2010: Updated and improved to make it compatible with MAMP ver. 1.9. If you are not a PECL auto make ninja, please resort to the manual build if PECL modules chapter, then it give you more fine grain control of the build process it self.
Uploadprogress or simply any PECL/PEAR module in MAMP
<
p>This howto will show you how to get those pesky PECL modules to compile in MAMP like uploadprogress or Xdebug. First a little Drupal background information. FileField and ImageField 3.0 for Drupal 6 released as one of many new features enables us to use the PHP extension uploadprogress that especially come in handy giving the user feedback of progress when uploading large files. Many OS X users are using MAMP to sandbox their development environment but compiling a PECL/PEAR module is not quite that easy in MAMP.
Content
Build uploadprogress in Leopard (version 10.5.x)
Build uploadprogress in Snow Leopard (version 10.6.x)
Manually build uploadprogress or any PECL extension out there.
Trouble shooting and links to prebuild modules and some word of warning.
When installing the Drupal module filefield-6.x-3.x you will in /admin/reports/status find a friendly warning telling you that the uploadprogress module is a nice addon.
Upload progress
Your server is capable of displaying file upload progress, but does not have the required libraries. It is recommended to install the PECL uploadprogress library (prefered) or to install APC.
As an early adopter I could not find any information on the web on how to compile and get a PECL PHP extension compiled and up and running under MAMP. After a day forth and back between pages I solved it, and decided to try and document is for other that are still struggling.
Leopard (10.5.x)
- Install Xcode Tools from your Mac OS X DVD or download it from Apple Developer Connection
- Download the complete PHP source code from php.net into /Applications/MAMP/bin/php5.2
- Create an include directory in the the php5.2 directory.
- Unzip/tar the php source archive and move it to /Applications/MAMP/bin/php5.2/include
- Rename the php source directory to just php (so then it will look like /Applications/MAMP/bin/php5.2/include/php)
- In Terminal use the following commands to compile the extension:
cd /Applications/MAMP/bin/php5.2/include/php
./configure
cd /Applications/MAMP/bin/php5.2/binIn MAMP 1.9.x and newer (I guess) the utilities in this directory are not executable (probably is this a safety proaction) make all these files executable, either by using Finder or from shell with:
sudo chmod a+x *
All the files in the directory should now be executable and you are all set to compile the extension:
sudo ./pecl i uploadprogress
- The result should be "Build process completed successfully". Now all you need is to move the newly compiled extension to the folder containing the existing PHP-extensions. On my system is it located at: /Applications/MAMP/bin/php5/lib/php/extensions/no-debug-non-zts-20050922 it might be slightly different on your configuration.
To help with finding the extensions directory, look at your phpinfo page from MAMP: Under "PHP Core" is the listing for "extension_dir" that will be the path you want to copy to. You can also use this same page to confirm that the extension is successfully enabled.
- Open the /Applications/MAMP/conf/php5.2/php.ini file and add extension=uploadprogress.so in the ; Extensions section.
- Restart MAMP and you should be all set.
To verify that the extension got successfully loaded by Apache, take a look in your phpinfo page from MAMP. Just search the page for "uploadprogress".
You can also manually start PHP from your command shell and ask what extensions it loaded:/Applications/MAMP/bin/php5.2/bin/php -m
Snow Leopard (10.6.x)
- Testet and updated to work with:
- MAMP 1.9
- PHP 5.2.14
- OS X 10.6.4
- Xcode: 3.2.2
Snow Leopard is almost identical to Leopard (and should be). A lot of people had problem loading the module they compiled (read comments bellow) on Snow Leopard. Snow Leopard introduced proper 64 bit support and Xcode compiled the module in 64bits mode only though MAMP 1.8/1.9 is still a 32bit (i386) application and loading a 64bit extension into a 32bit application is doomed. This is what worked on my system:
- Install Xcode Tools from your Mac OS X DVD or download it from Apple Developer Connection
- Download PHP 5.2.x complete source code from php.net.
- Create an include directory in your MAMP php5.2 directory
mkdir /Applications/MAMP/bin/php5.2/include
- Unzip/tar the php source archive into the newly created include directory and rename php-5.2.xx to php so your directory should read:
/Applications/MAMP/bin/php5.2/include/php
- Then to:
cd /Applications/MAMP/bin/php5.2/include/php
./configure - Before starting to compile do we need to do some GCC environment definitions, so paste this into your terminal:
MACOSX_DEPLOYMENT_TARGET=10.6
CFLAGS="-arch i386 -arch x86_64 -g -Os -pipe -no-cpp-precomp"
CCFLAGS="-arch i386 -arch x86_64 -g -Os -pipe"
CXXFLAGS="-arch i386 -arch x86_64 -g -Os -pipe"
LDFLAGS="-arch i386 -arch x86_64 -bind_at_load"
export CFLAGS CXXFLAGS LDFLAGS CCFLAGS MACOSX_DEPLOYMENT_TARGET - use the following commands to compile the extension:
cd /Applications/MAMP/bin/php5.2/bin
In MAMP 1.9.x and newer (I guess) the utilities in this directory are not executable (probably is this a safety proaction) make all these files executable, either by using Finder or from shell with:sudo chmod a+x *
All the files in the directory should now be executable and you are all set to compile the extension:
sudo ./pecl install uploadprogress
The result of from this command could in the end of log file read something like:Build process completed successfully
Installing '/usr/lib/php/extensions/no-debug-non-zts-20090626/uploadprogress.so'
install ok: channel://pecl.php.net/uploadprogress-1.0.1
configuration option "php_ini" is not set to php.ini location
You should add "extension=uploadprogress.so" to php.ini - If the build process completed successfully all you need is to copy the newly compiled extension to the folder containing the already existing MAMP PHP extension but where do you copy your newly compiled extension? To locate the directory look in your MAMP phpinfo page, search for "extension_dir" and you will find the path in used on your system or from command shell:
grep "extension_dir =" /Applications/MAMP/conf/php5.2/php.ini<code>
On my system was it located at /Applications/MAMP/bin/php5.2/lib/php/extensions/no-debug-non-zts-20060613/ it might be slightly different on your system, anyway on using my paths:
<code>cp /usr/lib/php/extensions/no-debug-non-zts-20090626/uploadprogress.so /Applications/MAMP/bin/php5.2/lib/php/extensions/no-debug-non-zts-20060613/ - With the extension safely located in the correct directory it is time to enable it. Open MAMP php.ini file (NOT the system global php.ini file that belongs to OS X) located at:
/Applications/MAMP/conf/php5.2/php.ini
and addextension=uploadprogress.so
to the "Dynamic Extensions" sectioni. - Restart MAMP and you should be all set.
To verify that the extension got successfully loaded by Apache, take a look in your phpinfo page from MAMP. Just search the page for "uploadprogress".
You can also manually start PHP from your command shell and ask what extensions it loaded: /Applications/MAMP/bin/php5.2/bin/php -m
Manually build your PECL extension
http://www.flickr.com/photos/grrphoto/ / CC BY 2.0
- Testet and updated to work with:
- MAMP 1.9
- PHP 5.2.14
- OS X 10.6.4
- Xcode: 3.2.2
No you don't need to be a Ninja to manually build an PECL module it normally involve a few more steps building the extension and be be very handy on computers with multiple PHP installations then makes it easier to control how to make the build and from where to include stuff.
- Install Xcode Tools from your Mac OS X DVD or download it from Apple Developer Connection
- Download PHP 5.2.x complete source code from php.net.
- Create an include directory in your MAMP php5.2 directory
mkdir /Applications/MAMP/bin/php5.2/include
- Unzip/tar the php source archive into the newly created include directory and rename php-5.2.xx to php so your directory path should read:
/Applications/MAMP/bin/php5.2/include/php
- Then do:
cd /Applications/MAMP/bin/php5.2/include/php
./configure - Download the PECL extension (normally pecl download uploadprogress will do the trick) and unpack it to you favourite directory and set up the GCC environment definitions to make sure we also get a i386 (32bit) version of the extensions so go ahead and paste the following into your terminal:
cd uploadprogress-version
/Applications/MAMP/bin/php5.2/bin/phpize
MACOSX_DEPLOYMENT_TARGET=10.6
CFLAGS="-arch i386 -arch x86_64 -g -Os -pipe -no-cpp-precomp"
CCFLAGS="-arch i386 -arch x86_64 -g -Os -pipe"
CXXFLAGS="-arch i386 -arch x86_64 -g -Os -pipe"
LDFLAGS="-arch i386 -arch x86_64 -bind_at_load"
export CFLAGS CXXFLAGS LDFLAGS CCFLAGS MACOSX_DEPLOYMENT_TARGET
./configure --with-php-config=/Applications/MAMP/bin/php5.2/bin/php-config
make
make install
The compiled module should now get copied to the correct extension directory and all you need to do is to restart the Apache MAMP server.
Still not working or are you just lazy?
http://www.flickr.com/photos/markjsebastian/ / CC BY-SA 2.0
If all of the above fails, read the instruction again and try to understand the steps, follow the carefully and keep a eye out for errors when MAMP is starting Apache. Monitor /Applications/MAMP/logs/php_error.log with Apple Console utility or from shell:tail -f /Applications/MAMP/logs/php_error.log
You can also try loading more information regarding the extension manually:/Applications/MAMP/bin/php5.2/bin/php --ri uploadprogress
This should give you something like:
uploadprogress
uploadprogress support => enabled
Version => 1.0.1
Directive => Local Value => Master Value
uploadprogress.file.filename_template => /var/tmp//upt_%s.txt => /var/tmp//upt_%s.txt
uploadprogress.file.contents_template => /var/tmp//upload_contents_%s => /var/tmp//upload_contents_%s
uploadprogress.get_contents => 0 => 0
A lot of the problem people are seeing trying to compile on Snow Leopard is related to PECL auto build are not correctly set up, and the pecl utility are building the extension by using the system wide PHP installation and/or the extension are build for 64bit programs only. MAMP (up to 1.9) are still running in 32 bit mode so loading a 64 bit version of your module in a 32 bits MAMP is futile. Check the compiled module:
file uploadprogress.so
uploadprogress.so: Mach-O universal binary with 2 architectures
uploadprogress.so (for architecture i386): Mach-O bundle i386
uploadprogress.so (for architecture x86_64): Mach-O 64-bit bundle x86_64
Does this this command tell you that it is only build for Mach-O 64-bit bundle x86_64 do you have an error in your PECL/PEAR config. Check for .pecl.default config files in your system that might cause you grief.
Still reading? Then I guess you are getting quite desperate, but not all hope is not lost. I have also provided two precompiled extensions:
- uploadprogress.so version 1.0.0 The extension is tested in MAMP 1.7.1, 1.7.2, 1.8.x under OS X version 10.5.x and 10.6.x.
- uploadprogress.so version 1.0.1 The extension is tested in MAMP 1.8.x and 1.9 under OS X version 10.6.x.
As usual you need to include the module in php.ini belonging to MAMP and restart the MAMP Apache server
Heads up if you have macports installed
Just a heads up...one thing that can cause headaches is if you have macports libraries installed that you have to link against....on Snow leopard if you don't edit /opt/local/etc/macports/macports.conf and uncomment this line build_arch i386 before you install the port it will compile using x86_64 architecture.....
Then when you try to build your extension (fileinfo in my case which needs libmagic installed) and point the config to look in /opt/local/ , if you are targeting 32 bit the build will crap out, and if you build in 64 bit obviously and you are downloading a precompiled version of 32 bit MAMP, then the extension won't load....anyhoo, I spose you could build MAMP from source in 64 bit as the other alternative.
Credits
This how to is largely build upon http://www.lullabot.com/about/nate-haug excellent article on how to Setup a Memcached-Enabled MAMP Sandbox Environment
Kommentarer
Adrian (ikke bekreftet)
27.4.2009
Permanent lenke
Just what I was looking for!
webmaster
27.4.2009
Permanent lenke
Step 7 incompleate
Keyz (ikke bekreftet)
27.4.2009
Permanent lenke
Once the extension is
Anonymous (ikke bekreftet)
28.4.2009
Permanent lenke
Thanks a lot, works like a
BlueStar (ikke bekreftet)
15.5.2009
Permanent lenke
not working
webmaster
24.5.2009
Permanent lenke
Sure?
Anonymous (ikke bekreftet)
25.5.2009
Permanent lenke
FYI I found that I didn't
Jeno (ikke bekreftet)
10.6.2009
Permanent lenke
No " Build process completed successfully"
webmaster
11.6.2009
Permanent lenke
What version of OS X are you running?
Jeno (ikke bekreftet)
11.6.2009
Permanent lenke
My setup
Jeno (ikke bekreftet)
11.6.2009
Permanent lenke
Apache
webmaster
15.6.2009
Permanent lenke
I think the problem is that
James (ikke bekreftet)
3.7.2009
Permanent lenke
move the newly compiled extension
webmaster
16.7.2009
Permanent lenke
Move uploadprogress.so
kyle (ikke bekreftet)
4.8.2009
Permanent lenke
Excellent instructions
webmaster
10.8.2009
Permanent lenke
Great tip
Ben (ikke bekreftet)
26.8.2009
Permanent lenke
Many thanks! works great!!
double (ikke bekreftet)
8.9.2009
Permanent lenke
uploadprogress not enabled
Andrew (ikke bekreftet)
15.9.2009
Permanent lenke
@double Same result for me :(
webmaster
16.9.2009
Permanent lenke
Could be a bug with ver
Lavanya (ikke bekreftet)
15.11.2009
Permanent lenke
Thanks and may this help you
webmaster
15.11.2009
Permanent lenke
Glad so many found this
Jonathan (ikke bekreftet)
18.9.2009
Permanent lenke
Not Working Either
webmaster
20.9.2009
Permanent lenke
Confirm problems with SL 10.6
webmaster
21.9.2009
Permanent lenke
Uploaded precompiled uploadprogress extension
ryosaeb4 (ikke bekreftet)
23.9.2009
Permanent lenke
I've try use the precompiled uploadprogress.do too but...
ryosaeb4 (ikke bekreftet)
23.9.2009
Permanent lenke
A issue in Snow Leopard
webmaster
23.9.2009
Permanent lenke
@ryosaeb4 You must have done
webmaster
25.9.2009
Permanent lenke
Problems under Snow Leopard solved
joln (ikke bekreftet)
13.10.2009
Permanent lenke
Thanks! Saved my day. :)
Sider