How to enable PECL uploadprogress extention in MAMP

MAMP

Uploadprogress in MAMP

FileField and ImageField 3.0 for Drupal 6 are now finally released, and the final release enables upload progress indication. This enhancement requires the PECL module uploadprogress that is a PHP extension. Many OS X users are using MAMP to sandbox their development environment.

Content

Build uploadprogress in Leopard (version 10.5.x)
Build uploadprogress in Snow Leopard (version 10.6.1)
Manually build uploadprogress or any PECL extension
Still having problems with uploadprogress? Try a prebuild module or read some word of warnings.

When updating to the final version 3 release you will get a friendly warning visiting the page admin/reports/status
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 PHP extension installed 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.)

apple_mac_os_x_10.5_leopard_1024x768_1.jpg

  1. Install Xcode Tools from your Mac OS X DVD or download it from Apple Developer Connection
  2. Download the complete PHP source code from php.net into /Applications/MAMP/bin/php5.
  3. Create an include directory in the the php5 directory.
  4. Unzip/tar the php source archive and move it to /Applications/MAMP/bin/php5/include
  5. Rename the php source directory to just php (so then it will look like /Applications/MAMP/bin/php5/include/php)
  6. In Terminal use the following commands to compile the extension
    "cd /Applications/MAMP/bin/php5/include/php"
    "./configure"
    "cd /Applications/MAMP/bin/php5/bin"
    "./pecl i uploadprogress"
  7. 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.

  8. Open the /Applications/MAMP/conf/php5/php.ini file and add extension=uploadprogress.so in the ; Extensions section.
  9. Restart MAMP and you should be all set.

Screen shot 2009-09-20 at 13.40.22.png

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 load PHP this way and it will tell you what extensions it uses:
/Applications/MAMP/bin/php5/bin/php -m


Snow Leopard (10.6)

snow-leopard1.jpg

Snow Leopard is almost identical to Leopard (and should be) except section 6. A lot of people had problem loading the compiled module (read comments bellow) in PHP. After a lot of trail and errors I managed to come up with a solution that worked (at my system at least)

This changes in section 6, first does we need to define some GCC env. 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

In Terminal use the following commands to compile the extension
cd /Applications/MAMP/bin/php5/include/php
./configure
cd /Applications/MAMP/bin/php5/bin
./pecl i uploadprogress


Manually build your PECL extension

152833988_dcba4bacd9.jpg
http://www.flickr.com/photos/grrphoto/ / CC BY 2.0

No you don't need to be a Ninja to manually build an PECL module. Just download the extension and unpack it to you favourite directory then:
cd uploadprogress-version
/Applications/MAMP/bin/php5/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/bin/php-configmake
make

The compiled module is now locate in modules and you need to copy it to the correct PHP extension directory. As usual you need to include the module in php.ini belonging to MAMP and restart the MAMP server.


Still not working or are you just lazy?

3318930880_5344b6af33.jpg
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. Still reading? Then I guess you are getting quite desperate, but not all hope is lost. I have uploaded some precompiled extensions:

  1. 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.
  2. uploadprogress.so version 1.0.1 The extension is tested in MAMP 1.8.x 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 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

Comments

Just what I was looking for!

Just what I was looking for! But step 7 seems incomplete, right?

Step 7 incompleate

Good catch! Step 7 is now fixed.

Once the extension is

Once the extension is compiled and moved into MAMP's own extension's directory, does the extra downloaded copy of PHP need to remain, or can it be deleted?

Thanks for the lesson by the way, I was wondering about how to do this in MAMP.

Thanks a lot, works like a

Thanks a lot, works like a charm!!

not working

Hi!
Once I get to "./pecl i uploadprogress"
I get this error message:


No releases available for package "pecl.php.net/uploadprogress"
Cannot initialize 'channel://pecl.php.net/uploadprogress', invalid or missing package file
Package "channel://pecl.php.net/uploadprogress" is not valid
install failed

I think the link is incorrect, because it should be: http://pecl.php.net/get/uploadprogress

Help anyone?
thanks!
bluestar

Sure?

Did you run:
"./pecl i uploadprogress"

FYI I found that I didn't

FYI I found that I didn't need to install the complete PHP Source Code into MAMP. Once I downloaded xCode Tools I was fine.

No " Build process completed successfully"

Thanks for the guild but I couldn't get a success installation.

I get the error below:

uploadprogress.c:75: error: 'MULTIPART_EVENT_START' undeclared (first use in this function)
/Users/jenoloo/temp/uploadprogress/uploadprogress.c:75: error: (Each undeclared identifier is reported only once
/Users/jenoloo/temp/uploadprogress/uploadprogress.c:75: error: for each function it appears in.)
/Users/jenoloo/temp/uploadprogress/uploadprogress.c:76: error: 'multipart_event_start' undeclared (first use in this function)
/Users/jenoloo/temp/uploadprogress/uploadprogress.c:76: error: 'e_data' undeclared (first use in this function)
/Users/jenoloo/temp/uploadprogress/uploadprogress.c:77: error: parse error before ')' token
/Users/jenoloo/temp/uploadprogress/uploadprogress.c:87: error: 'MULTIPART_EVENT_FORMDATA' undeclared (first use in this function)
/Users/jenoloo/temp/uploadprogress/uploadprogress.c:89: error: 'multipart_event_formdata' undeclared (first use in this function)
/Users/jenoloo/temp/uploadprogress/uploadprogress.c:90: error: parse error before ')' token
/Users/jenoloo/temp/uploadprogress/uploadprogress.c:124: error: 'MULTIPART_EVENT_FILE_START' undeclared (first use in this function)
/Users/jenoloo/temp/uploadprogress/uploadprogress.c:127: error: 'multipart_event_file_start' undeclared (first use in this function)
/Users/jenoloo/temp/uploadprogress/uploadprogress.c:129: error: parse error before ')' token
/Users/jenoloo/temp/uploadprogress/uploadprogress.c:146: error: 'MULTIPART_EVENT_FILE_DATA' undeclared (first use in this function)
/Users/jenoloo/temp/uploadprogress/uploadprogress.c:147: error: 'multipart_event_file_data' undeclared (first use in this function)
/Users/jenoloo/temp/uploadprogress/uploadprogress.c:149: error: parse error before ')' token
/Users/jenoloo/temp/uploadprogress/uploadprogress.c:163: error: 'MULTIPART_EVENT_FILE_END' undeclared (first use in this function)
/Users/jenoloo/temp/uploadprogress/uploadprogress.c:164: error: 'multipart_event_file_end' undeclared (first use in this function)
/Users/jenoloo/temp/uploadprogress/uploadprogress.c:166: error: parse error before ')' token
/Users/jenoloo/temp/uploadprogress/uploadprogress.c:176: error: 'MULTIPART_EVENT_END' undeclared (first use in this function)
make: *** [uploadprogress.lo] Error 1
ERROR: `make' failed

Thanks

What version of OS X are you running?

What version of OS X are you running?
What PHP version did you download?

It is not finding any or some lib from PHP when it compiles the plugin.

My setup

I am running on my test machine which is my laptop running Mac OS X 10.4.10. + drupal 6.12 + MAMP Pro 1.7.2 (I think it won't make any difference if I am using the free version of MAMP).

Thanks

Apache

PHP Version 5.2.6

I think the problem is that

I think the problem is that you are running ver. 10.4 (not 100% sure)
You could test it by manually downloading the extension and unpack it (anywhere). then run:
phpize (This makes the "build files". If that worked)
./configure
make

phpize is a part of the system wide installed PHP and it is prob. to old release: Try "whereis phpize" and the shell will tell you what location.

This is from my OS X ver. 10.5.6:
"phpize --version"
Configuring for:
PHP Api Version: 20041225
Zend Module Api No: 20060613
Zend Extension Api No: 220060519

"php -v"
PHP 5.2.8 (cli) (built: Feb 5 2009 21:21:13)
Copyright (c) 1997-2008 The PHP Group
Zend Engine v2.2.0, Copyright (c) 1998-2008 Zend Technologies

move the newly compiled extension

HI Thanks for this. I finished up to the end of the terminal bit, got the "Build process completed successfully" but I'm confused about which file needs to be moved where? Should there be a new file created in the newly created 'include' directory that I need to move? Thanks

Move uploadprogress.so

The compilation create an extension named uploadprogress.so. This is the file you need to move.

Excellent instructions

Well done, thanks. 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.

Great tip

That is a great tip Kyle, I'll add this information about how to find your extension_dir to the how to. Thanx!

Many thanks! works great!!

Many thanks! works great!!

uploadprogress not enabled

Thanks for the instructions... I tried to compile and install uploadprogress following the instructions above, and it looks like everything went well, but the extension does not seem to be enabled.

I am on OS X 10.6 running mamp v. 1.8.1 with php 5.2.10. I added the appropriate line to php.ini and made the uploadprogress.so file was executable.

Am I missing something or are there any known conflicts I should look out for?

....
Build process completed successfully
Installing '/Applications/MAMP/bin/php5/lib/php/extensions/no-debug-non-zts-20060613/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
...

@double Same result for me :(

I'm running MAMP v.1.7.2 on OS 10.5.8 & using PHP Version 5.2.6.

When I try "php --ri uploadprogress" I get:

PHP Warning: PHP Startup: uploadprogress: Unable to initialize module
Module compiled with module API=20090626, debug=0, thread-safety=0
PHP compiled with module API=20060613, debug=0, thread-safety=0
These options need to match
in Unknown on line 0
Extension 'uploadprogress' not present.

Could be a bug with ver

Could be a bug with ver 1.0.1. I'll try and do some tests and post back my results, interesting....

Not Working Either

I've tried twice now to follow these instructions, but without success. I tried once with my original install of MAMP. Everything completed successfully, I moved the uploadprogress.so into the correct folder and changed the PHP.ini. Still didn't work. So, just in case I screwed up, I re-installed the latest version of MAMP, downloaded the latest version of PHP, and followed the steps. Again, no error messages, but I can't find uploadprogress on the PHPinfo page and my Drupal site still indicates that it's not installed. Any idea? Where exactly should I check on the PHPinfo page for evidence that it's actually installed. Thanks for the tutorial.

Confirm problems with SL 10.6

I have done some more tests on a MAMP ver 1.7.1 setup under 10.6.x. This computer is upgraded from 10.5.x with an existing working MAMP env.

phpize
Configuring for:
PHP Api Version: 20090626
Zend Module Api No: 20090626
Zend Extension Api No: 220090626

Compiled successfully uploadprgress ver 1.0.1 with GCC ver. 4.2.1 (current running XCode release), but MAM/Apache is not able to load it. Did the same ting with uploadprgress 1.0.0 that also have problem loading under 10.6..

Uploaded precompiled uploadprogress extension

Have done some more debugging and I think the problem is that PHP is compiled in 32 bit mode, but when you compile on 10.6 modules by default get compiled in 64 bit mode:

file uploadprogress.so
uploadprogress.so: Mach-O 64-bit bundle x86_64
Get compiled GCC in 10.6.x

uploadprogress.so
uploadprogress.so: Mach-O bundle i386
Compiled in 10.5.x and are working.

I have uploaded a precompiled uploadprogress.so to try and help you out until we have solved this problem. The extension is tested and is working in MAMP 1.7.1, 1.7.2, 1.8.x under OS X ver. 10.5.x and 10.6.x.

A issue in Snow Leopard

Dear Friends

I've this error in SNOW LEOPARD (after section 6 of this tutorial)

sh-3.2# ./configure
creating cache ./config.cache
checking for Cygwin environment... no
checking for mingw32 environment... no
checking for egrep... grep -E
checking for a sed that does not truncate output... /usr/bin/sed
checking host system type... i686-apple-darwin10.0.0
checking target system type... i686-apple-darwin10.0.0
checking for gcc... no
checking for cc... no
configure: error: no acceptable cc found in $PATH
sh-3.2# cd /Applications/MAMP/bin/php5/bin
sh-3.2# ./pecl i uploadprogress
WARNING: channel "pecl.php.net" has updated its protocols, use "channel-update pecl.php.net" to update
downloading uploadprogress-1.0.1.tgz ...
Starting to download uploadprogress-1.0.1.tgz (8,536 bytes)
.....done: 8,536 bytes
4 source files, building
running: phpize
Configuring for:
PHP Api Version: 20090626
Zend Module Api No: 20090626
Zend Extension Api No: 220090626
Cannot find autoconf. Please check your autoconf installation and the $PHP_AUTOCONF
environment variable is set correctly and then rerun this script.

ERROR: `phpize' failed
sh-3.2# ERROR: `phpize' failed

And IF I try this:

sh-3.2# phpize
Cannot find config.m4.
Make sure that you run '/usr/bin/phpize' in the top level source directory of the module

Why It not work?

I've try use the precompiled uploadprogress.do too but...

Well I've try to download the precompiled uploadprogress.so from here: http://smbjorklund.no/sites/smbjorklund.no/files/uploadprogress.so

I've put it on my /Application/MAMP/bin/php5/lib/php/extension/no-debug-non-zts-20050922

And I've restart MAMP but It not work, WHY???

Somebody help me please?

@ryosaeb4 You must have done

@ryosaeb4
You must have done something wrong prior to point 6.
Autoconf is part of Xcode check if it is installed by
ls -l /Developer/usr/bin/autoconf

If you are trying manually to build the extension make sure you run the phpize that is a part of MAMP (/Applications/MAMP/bin/php5/bin/phpize), OS X also ship with phpize and make sure you are in the top level dir of the module source code.

Remember to include the extension in your MAMP php.ini file and look for problems inside your /Applications/MAMP/logs/php_error.log

Problems under Snow Leopard solved

Just in case you guys have not noticed it, I solved the issue regarding making this work in Snow Leopard few days ago and updated this article. I also added a section about manually compiling en PECL extension.

Cheers
Steinmb

well done

Yes, well done, I use this feature on coupons website and it's working very well

Thanks! Saved my day. :)

Thanks! Saved my day. :)

Good work!

Thanks.... for sharing. Good work, keep it up.

Thanks

Thanks for the pre-compiled extension. Saved me lots of time. :D

Thanks and may this help you

Hi

I thank for this article on PECL uploadprogress for MAMP this helped to do that.

I got same warning and I deleted and installed MAMP many times did same but again I got same
PHP Warning: PHP Startup: uploadprogress: Unable to initialize module
Module compiled with module API=20090626, debug=0, thread-safety=0
PHP compiled with module API=20060613, debug=0, thread-safety=0
These options need to match
in Unknown on line 0

But I later found that my MAMP php version is 5.2.11 and I was downloading
php 3.0 stuff and following same method and failing.

LOL then I saw a little below downloaded tar.gz for php 5.2.11 and now all is well...

I am posting this if any did same like me and didn't observe error they are doing may be getting frustrated like me LOL...

well done in this article thanks again

Glad so many found this

Glad so many found this article useful. There is a lot of pitfalls out there ;)

php settings

on 10.6 system present system php 5.3 and mamp php 5.2.*
when I try to compile for mamp it compile for system php 5.3
how to say in console, php to compile with mamp php.ini?

@Andre: That is correct, that

@Andre: That is correct, that is the reason you need to follow the Snow Tiger section in this how to and hopfully you will have not have any problems.

loaded... but

ok by comand
/mamp-path/php -m
uploadprogress loaded
I restart MAMP
but phpinfo show that uploadprogress not loaded

@andre: Getting close now :)

@andre: Getting close now :) Check your MAMP php.ini file, you must be missing something there.

close.. ? in

close.. ?
in phpinfo
Configuration File (php.ini) Path /Applications/MAMP/conf/php5

NEXT file is new after mamp reboot.
Loaded Configuration File
/Library/Application Support/appsolute/MAMP PRO/conf/php.ini

file /Applications/MAMP/conf/php5/php.ini not printed in that table.
where is original data for /Library/Application Support/appsolute/MAMP PRO/conf/php.ini ? (

Have never used MAMP pro.

Have never used MAMP pro. Check your php_info() setting, It will tell you what php.ini that is in use.

thanks a lot ! mamp pro

thanks a lot !
mamp pro autocreate ini-files from templates (File-Edit Templates)
do not forget to copy *.so files to right place.

Thanks A lot! You gave the

Thanks A lot!

You gave the info I needed in a clean simple manner that even a noob like me could understand.

Thanks a lot, that snippet

Thanks a lot, that snippet was impossible to figure out !

MACOSX_DEPLOYMENT_TARGET=10.6CFLAGS="-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

Just a heads up...one thing

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.

Thanx @jon! I have included

Thanx @jon! I have included you tip in the how to. If you have not shared this information with with us I would never have known :)

you're a champion! I could

you're a champion!
I could not get it load, tried it all.

Finally downloaded your pre-complied .so and it work perfectly!
I must have screwed up the compile somewhere.
Thank you!

Thank god for your

Thank god for your precompiled so! I get my server done but i never get my laptop done, i get stuck on this problem for two days already! Thanks so much, you are my angel.

Thank you for this! I have

Thank you for this! I have used it to try to install oauth.so.

I followed the instructions, suitably amended, and oauth.so is in the right place and the extensions line in php.ini is correct. However, I get the following error when I restart mamp:

[26-Feb-2010 15:05:35] PHP Warning: PHP Startup: Unable to load dynamic library '/Applications/MAMP/bin/php5/lib/php/extensions/no-debug-non-zts-20060613/oauth.so' - (null) in Unknown on line 0

What did I do wrong?

Rob

Hi Rob Have no idea what the

Hi Rob
Have no idea what the problem is regarding http://pecl.php.net/package/oauth You could try to follow the manual compile instruction in the how to.

Post new comment

The content of this field is kept private and will not be shown publicly.
  • Web page addresses and e-mail addresses turn into links automatically.
  • Allowed HTML tags: <a> <em> <strong> <cite> <code> <ul> <ol> <li> <dl> <dt> <dd> <img> <h2> <h3> <h4> <embed>
  • Lines and paragraphs break automatically.

More information about formatting options