Max says…

Avatar

thoughts of a web developer

Revert to PHP 5.2 in Ubuntu 10.04 (Lucid Lynx)

Despite suppressing updates of my LAMP stack, the upgrade to Ubuntu 10.04 ignored that, and as such I now have PHP 5.3.X installed.  Ordinarilly this woud be fine, but one of the open source web applications I work with doesn’t play well with PHP 5.3.X.  I needed a simple way to revert to a previous 5.2.X version of PHP.  The version in the Ubuntu 9.10 (Karmic) repositories would do the trick, so it was jsut a case of forcing Ubuntu to honour the 9.10 versions of various PHP packages over the 10.04 versions.

First, we get a list of all the currently installed PHP packages:

sudo dpkg -l | grep php > /tmp/php.packages

Next we remove the currently installed PHP packages:

sudo apt-get remove --purge $(dpkg -l | grep php)

Now we need to create an alternative sources list:

sed s/lucid/karmic/g /etc/apt/sources.list |\
sudo tee /etc/apt/sources.list.d/karmic.list

Having done that, we need to generate an aptitude preferences file for PHP:

awk '{print "Package: " $0; print "Pin: release a=karmic\nPin-Priority: 991\n"}' /tmp/php.packages |\
sudo tee /etc/apt/preferences.d/php

This preferences file tells aptitude that for each listed package, we want to pin down the installation candidate to that from the Karmic repositories. We can now install the packages that we previously removed, but this time the versions from the Karmic repositories:

sudo apt-get install $(cat /tmp/php.packages | tr "\n" " ")

A quick restart of Apache and everything seems to be working with the older version of PHP!

Continue in Interactive Bash Loop

Came across a useful keyboard shortcut to continue to the next iteration of an interactive bash for loop.  Let’s say you have something like:

for i in $(cat server_list.txt); do
   ssh -q $i hostname
done

If one of the servers is unresponsive, you can continue to the next iteration with

ctrl + \

Ubuntu 8.10 Intrepid Ibex

Having upgraded my Hardy distribution to Intrepd, I can say that I’m impressed.  The changes to the desktop, although subtle, are very much welcome.  I haven’t had any teething troubles with any of my hardware; the only ‘glitch’ I’ve noticed involves the title bars of open applications, it goes transparent now and then – but I’m sure I can put up with it until it gets fixed.  Good work Ubuntu!

Find Excluding SVN

So, you need to take a copy of a subversion working copy, but it has local changes that you also need to copy.  This precludes the use of `svn export` since the local changes won’t be included.  One option is to do an `svn export` anyway, and then `cp -ra` the local changes.  Another solution is to use a find command that excludes subversion metadata, and then copy the resulting files:

`find . -path ‘*/.svn’ -prune -o -type f -print`

I did something similar some time ago, but forgot the command, so here it is for posterity.

Playing With Perl Sockets

At work, I have a Snom 360 IP phone that is hooked up to our internal Asterisk PBX.  If I’m listening to music with my headphones in, I’m not always aware that my phone is ringing – some Perl and PHP hacking later, I’ve got a crude (and work-in-progress) solution. [Read more]

Samba: Linux to Linux Gotcha

It’s been a long time coming, but I’ve finally got my machine at work set up using Ubuntu 8.04 rather than Windows XP.  I’ve been using Ubuntu at home almost exclusively for nearly a year now, so it’s good to be able to maintain my workflow from home to work.  One of the problems I had was mounting  my home directory on a server.

On windows, this works fine: you specify a username, a password, and the share you want to connect to and it just works.  The same is almost true with linux: you specify the username, password and share (either on the command line or in /etc/fstab).  However, chances are your local UID will differ from the UID used on the server, so although the mount will succeed, permissions may be a bit iffy.

The solution was to use CIFS rather than the outdate smbfs, and to use the extra uid option:

$ sudo mount -t cifs -o username=user,password=pass,uid=1000 //server/share /local/mount/point

This makes sure that the share you mount is owned by the local user.

Banshee 1.0 – iPod Compatible Media Player

I’ve spoken before on this site about Songbird, a viable Linux alternative to iTunes. Since my original post, I haven’t really kept up with Songbird; perhaps I should have; perhaps I will. However, in the meantime I have had Banshee 1.0 brought to my attention.

I originally used Banshee as it’s UI is similar to iTunes. I have also spoken before that although I am right at home with Ubuntu and Linux in general, I do miss a good media manager; iTunes ticks all the boxes for me and is indispensable since I use an iPod. Banshee has pulled out the stops with the recent release of it’s first major release, version 1.0

Banshee 1.0 is a massive improvement on the older version that I had initially dismissed as being too clunky; so much so that I’m going to use it instead of Rhythmbox. Although not compatible with the most recent iPod software, it is fully compatible if you reinitialise your library and use an older version of the software on your iPod. Since I don’t really use video or images on my iPod that’s fine by me.

The interface is much cleaner and it is clear that a lot of time has been spent polishing it. Last.FM is built in, as is a ‘favourites’ and ‘recently added’ play list. These last features were missing from Rhythmbox and I really liked them in iTunes. In addition, there is an “Unheard” playlist – now I can make a point of listening to the tracks that I forgot I even had!

In summary – a big thumbs up from me to the Banshee development team. Banshee 1.0 is a more mature and usable piece of software that it’s predecessor and I look forward to seeing it develop further. Having said that, I will take another look at Songbird…

A nice alternative to GIMP on Ubuntu

I’m not one of the many ardent Microsoft haters that use Linux, and as such I’m quite open to taking full advantage of whatever software I can to get the job done, whether I’m in Linux or Windows. I really quite like Paint.Net which I’ve used on Windows as an alternative to Photoshop and the GIMP. You can now get Paint.Net on Linux courtesy of the Mono framework:

$ sudo apt-get install mono-common libmono* mono-gmcs
$ svn co http://paint-mono.googlecode.com/svn/trunk/src paint-mono
$ cd paint-mono
$ ./configure
$ make
$ make install
$ paintdotnet

I’ve been informed by someone commenting on this post that the above doesn’t appear to work any more, the below is command line output of a successful install, hope it helps.

$ cd /tmp
$ wget http://paint-mono.googlecode.com
   /files/paintdotnet-0.1.63.tar.gz
$ tar xvfz paintdotnet-0.1.63.tar.gz
$ ./configure
Looking for required packages
Checking for revision…
paintdotnet has been configured with
prefix = /usr/local
config = RELEASE_AND_PACKAGE_ANY_CPU
$ make
$ sudo make install
…
make post-install-local-hook prefix=/usr/local
…
$ cd /usr/local/bin
$ ls -ltr | tail -n1
paintdotnet
$ ./paintdotnet

Hardy and Firefox

As I mentioned in my last post, I have had issues getting Firebug working in Firefox 3.0b5.  Unfortunately at the moment Firebug isn’t compatible with the beta release of Firefox 3.  To be honest, I’m quite happy with Firefox 2.x.  From what I’ve read, Firefox 3 is more stable and less memory-hungry that its predecessor, and it does look nice (especially so according to Mac users).  Unfortunately, these benefits are outweighed by my love of the Firebug extension.  It is, in my opinion, the best debug tool for web developers bar none.  To that end, I’ve chosen to remove Firefox 3 (and all the bits and bobs that come with it) and install Firefox 2.

A few apt-gets later, I had got rid of Firefox-3 and related packages, and installed Firefox-2, symlinked to /usr/bin/firefox.  However, Firefox-2 still used the profile created by Firefox-3 in my home directory.  I started Firefox from the terminal, with the ‘-ProfileManager’ switch.  I created a new profile, renamed default, and renamed my new profile to default.  I then copied my bookmarks and related data from the old profile directory to the new one.  Once this was done, I started Firefox with my new default profile,  installed my favourite plugins and all was good – Firebug now works like a dream!

Hardy Upgrade

The latest stable release of Ubuntu linux (Hardy Heron) was released this week, and having eagerly awaited its release I decided to upgrade my desktop and laptop from Ubuntu 7.10 to 8.04.  I’m going to keep my server on 7.10 for the time being however.

The upgrade went surprisingly smoothly.  It was just a matter of ‘sudo apt-get update’, ‘sudo apt-get upgrade’ and ‘sudo apt-get dist-upgrade’.  After an hour or so, the installation was complete and I rebooted.

I had a few issues with both my laptop and desktop, but these were resolved fairly easily.  The Realtek sound on my laptop was supported via linux-backports-modules-generic.  This didn’t seem to be available in Hardy, and neither the old ALSA, nor the new Pulse Audio Server seemed to support my Realtek onboard audio.  A bit of searching on the Realtek website revealed linux drivers, which I promptly downloaded, unzipped and installed.  Success!

When my desktop came back up after the reboot, the keyboard seemed to have a delay of a number of seconds, and would intermittently behave as if a key had held down.  Also, Gnome didn’t come up properly, with the desktop being black.  I rebooted again and everthing seemed fine… for now.

Firefox 3.0b5 comed preinstalled with Hardy.  Unfortunately, the brilliant Firebug web developer extension isn’t compatible with this version of Firefox.  I hope that the final release of Firefox will fix this compatibility issue.  For the time being, I will have to install Firefox 2.x to allow me to use Firebug.

In summary, I’m very impressed with how easy and smoothly the upgrade went.  Aside from a few small issues everything worked fine after the upgrade, it’s just a shame about including a prerelease web browser in a LTS release of Ubuntu.  Perhaps they should have stuck with Firefox 2.x until Mozilla officially released version 3 of their excellent browser.

Next,