Installing the PEAR/PECL uploadprogress extension for Drupal 7

September 16th, 2009 Posted in System administration | No Comments »

Trying out the latest development snapshot of Drupal 7, I noticed it supports the uploadprogress PEAR/PECL extension, which apparently lets you see the actual progress (with some kind of Ajaxy widget) while uploading files. Sounds cool to me.

First, I installed PEAR (on my Ubuntu testing server):

$ sudo aptitude install php-pear

and then tried to use PEAR to install uploadprogress:

$ sudo pear install pecl/uploadprogress
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
sh: phpize: not found
ERROR: `phpize' failed

PHPize? What’s that? There’s no phpize package; aptitude search phpize gives nothing.

A bit of digging and I found that PHPize is part of the php5-dev package! After installing that, pecl can install a module just fine:

Solution

$ sudo apt-get install php5-dev
$ sudo pear install pecl/uploadprogress

After lots of output, PEAR left a final clue:

configuration option "php_ini" is not set to php.ini location
You should add "extension=uploadprogress.so" to php.ini

So I created /etc/php/conf.d/uploadprogress.ini, containing just this line:

extension=uploadprogress.so

I restarted Apache and now Drupal 7 reports “UPLOAD PROGRESS: Enabled”. Now to try it out….!

Installing the mysql Ruby gem

August 1st, 2009 Posted in System administration | No Comments »

While trying to install this gem on Ubuntu 8.04.3 (Hardy) to run a rails app (Redmine), I encountered the following error:

$ sudo gem install mysql
Building native extensions.  This could take a while...
ERROR:  Error installing mysql:
        ERROR: Failed to build gem native extension.

/usr/bin/ruby1.8 extconf.rb
extconf.rb:1:in `require': no such file to load -- mkmf (LoadError)
        from extconf.rb:1

There are a bunch of common errors when installing the mysql gem, so Googling for the solution wasn’t instant. Luckily I found this post which showed the missing package: ruby1.8-dev.

Solution

sudo apt-get install ruby1.8-dev

and the MySQL gem installed fine.

gem won’t install Ruby gems on VPS…

July 28th, 2009 Posted in System administration | No Comments »

Having trouble installing Ruby gems on your VPS? Gem was hanging on my Slicehost slice (running Ubuntu Hardy with 256MB of RAM) at “Bulk updating [...]“:

$ gem update
Updating installed gems...
Bulk updating Gem source index for: http://gems.rubyforge.org

It was also gobbling up CPU and memory.

Why does gem hang?

The distro package for Gem is very old, and this old version uses a lot of memory, causing lots of disk thrashing. Since hard disks are, ahem, a bit slower than RAM, this increases gem’s run time by probably a few orders of magnitude.

Solution

Update gem manually:

$ wget http://rubyforge.org/frs/download.php/57642/rubygems-update-1.3.4.gem
$ sudo gem install rubygems-update-1.3.4.gem
$ sudo /var/lib/gems/1.8/bin/update_rubygems
Installing RubyGems 1.3.4
Installing RubyGems
Installing gem executable
Removing old source_cache files
Removing old RubyGems RDoc and ri
Installing rubygems-1.3.4 ri into /usr/lib/ruby/gems/1.8/doc/rubygems-1.3.4/ri
Installing rubygems-1.3.4 rdoc into /usr/lib/ruby/gems/1.8/doc/rubygems-1.3.4/rdoc

RubyGems installed the following executables:
/usr/bin/gem1.8

Looks like everything’s OK, but gem didn’t work anymore:

$ sudo gem install haml
/usr/bin/gem:10: undefined method `manage_gems' for Gem:Module (NoMethodError)

What gives? Notice the path, /usr/bin/gem. Is that still the old version?

$ ls -lah /usr/bin/gem*
-rwxr-xr-x 1 root root 701 Nov 19  2007 /usr/bin/gem
-rwxr-xr-x 1 root root 545 Jul 28 00:15 /usr/bin/gem1.8

Yes. This is what we get for upgrading gem without using Ubuntu’s package system. Well, in for a penny, in for a pound:

sudo mv /usr/bin/gem1.8 /usr/bin/gem

Done. Now to install Haml and Sass….