15th Jan2013

Install php-gd on Ubuntu without recompiling php

by Gyro

For some reason one of my client's website stopped showing captcha codes for the mad4joomla component, the server is running nginx with php-fpm instead of Apache.

Looking at the error.log, I got

 [error] 21110#0: *100 FastCGI sent in stderr: "PHP message: PHP Fatal error:  Call to undefined function imageantialias() in /var/www/clients/client1/web1/web/components/com_mad4joomla/sec/im4.php on line 39"

Time to check the server, that function is supposed to be part of the GD library.

First, I checked if GD was loaded:
# php5 -m | grep -i gd


ok, so GD is there… now on to the function.

# php -r "var_dump( function_exists(‘imageantialias'));"


hmm… :wooty:

So, on I went to google, trying to find out how I can get imageantialias() to work (again)… to my surprise I actually stumbled upon a post talking about the exact same issue, while using the same server setup -- Ubuntu with ISP Config. The solution presented was to recompile php, which I was reluctant to do.

After some more searching I came across this amazing little page (http://nossie.addicts.nl/php5-gd.html) which I am going to post (slightly modified) right here, mainly because it looks like that page could be gone tomorrow…

Getting bundled php-gd working on Ubuntu without having to recompile php

Like many other people out there, I ran into the problem that the version of php-gd shipped with Ubuntu (and Debian) is different from the version used by many other distributions.
The version Ubuntu uses misses some functions like imagerotate and imageantialias, which are needed by an increasing number of software projects.

One solution to this problem is recompiling PHP with the bundled version of GD.
It is not particularly hard to do, but there are a reasons not to do it, one of them being that it is not neccesary.

The following steps solved the problem for me.

Install what is needed to do this:
# sudo apt-get install php5-cli php5-gd rpm mc

Check what version of php you are running (php5 -v). In my case it was 5.3.2-1ubuntu4.7
Go to rpmfind.net and search for php-gd-bundled
Download the version that matches your PHP version and architecture, php-gd-bundled-5.3.2-1mdv2010.1.x86_64.rpm in my case.

If you have installed mc (midnight commander) and rpm, you can use mc to open the downloaded .rpm file (start mc, goto the .rpm file and hit enter)
Inside the .rpm file you will see CONTENT.cpio, navigate to that and hit enter. Goto usr/lib64/php/extensions, there you will find gd-bundled.so.

The original php5-gd is installed at /usr/lib/php5/20090626/gd.so (for my installation), backup the original gd.so, and copy the gd-bundled.so to that location and rename to gd.so (you can copy files with F5 in mc).
The new gd.so expects to find libjpeg.so.8, this was not present on my system, but that can be sovled by creating a symlink from the installed libjpeg.so
On my system I found /usr/lib/libjpeg.so.64.0.0
Create the symlink with:
# ln -s /usr/lib/libjpeg.so.62.0.0 /usr/lib/libjpeg.so.8

This is it, restart apache and you should be running with the bundled version of gd.
# php -r "var_dump(function_exists(‘imageantialias'));"
Should return bool(true) this time.

Now, if there is an update of the php5-gd package, your modified version gets overwritten. To prevent this from happening, you can hold the php5-gd package so it will not be updated.
# aptitude hold php5-gd

I hope this will help you as much as it did me!

Enjoy :enjoy:


14th Jan2013

Search Engine Friendly SEF URLs for Virtuemart 1.1.9

by Gyro

While I still hate joomla, today I stumbled across a neat solution to have virtuemart 1.1.9 use SEF URLs.

All that is required to make it work is turn on SEF URLs in the Global config, disable the suffix, and copy a file into your components/com_virtuemart folder.

You can get all the details here

Enjoy  :enjoy:


10th Jan2013

Why I hate Joomla – Episode 1: URL suffix

by Gyro

Today I had really good fun with Joomla, that is, if you consider cursing and face-palming to be fun.

I have been using CMS systems since 2000 when I first installed php-Nuke. Shortly after that I used xoops to create a website for my clan, xoops is still one of my favorite CMS systems actually, even though WordPress is simply the best IMHO.

I did use Drupal, and actually liked when the developers split and Joomla was born. Now, I have started hating Joomla shortly after it was released. Main reason being their elitism in the forum, it seems that everyone has to comment but no-one actually comes up with genuine solutions. I would never even open their website again, had I no customers with Joomla websites, but since I do, I am on and off forced to deal with this piece of sunshine CMS.

So, now to the 2nd reason of probably 100+ to come:
I have just spend about 4 hours searching for a solution to get Joomla 1.5 to add a trailing slash (/) to the URL, instead of the default .html suffix. I found quite a lot of threads on the Joomla forum discussing how one could add a trailing slash instead of the .html suffix, and once again each thread was gang banged by Joomla Gurus making dumb a…smart comments, and a solution was nowhere to be found, unless you want to use a plugin. I swear, I would have slapped a few of them, were they near me when reading their useless comments… of course I can use a plugin like sh404 that completely hijacks your site and URL structure, but I was looking for the solution, not a work around!

So, after those 4 hours I finally got my Geany out of the bottle and did a few in-file searches, to find the files with the lines that does all the magic.

It is the router.php located in includes/router.php, open it and look for the function &build($url), and change the following within that function:

//Transform the route
$route = str_replace(‘index.php/', ", $route);

To this:
//Transform the route
$route = str_replace(‘index.php/', ", $route).'/';

Next, open libraries/joomla/document/html/renderer/head.php and look for this:

 if(!empty($base)) {
$strHtml .= $tab.'<base href="‘.$document->getBase().'" />'.$lnEnd;

change the above to this:

 if(!empty($base)) {
$strHtml .= $tab.'<base href="http://'.$_SERVER[‘SERVER_NAME'].'/" />'.$lnEnd;

You may have to modify this part a bit (maybe https, or if Joomla is installed in a sub folder, etc.), basically you should have your Homepage URL in the baseurl meta tag in the head section of the source code. :)

That's it! It really is that simple :shock: which makes me even more furious :shout: … I mean appreciative… thinking about all the super smart comments I found in the Joomla forum. I was about to go back to the Joomla forum to post my solution and tell those "Joomla Gurus" how full of sunshine they are, but then I remembered that I got this blog.

Oh, you need to disable showing the URL suffix in the Global Configuration, of course!

Enjoy! :hehehe:

p.s. Operating a blog is a fine form of anger management… :crazy: