Saturday, December 31, 2011

A SEO Story

While pretotyping my mu{d}sings site, I thought a Dracula timeline would be a very good addition. mu{d}sings is about all things making text fun: interactive fiction, text based multi user dungeons, story writing and so on. You can find the latest news in this space on the forums via a news aggregator. But this is another story...

To test the technologies around making text fun, I am using a fictional world, Haven, whose story happens in the Eastern Europe during Dracula's time. Many history making things happened then, for example the fall of Constantinopole and the mighty feats of heroism and courage to stop the Ottoman empire from taking over the Western world.

There is too much to say and a timeline would present all these details at a glance.

There is a great javascript timeline component, called SIMILE, from It is easily integrated in Joomla via a content plugin called ws_timeline :

To include the Dracula timeline on a Joomla we need to create an article and add the plugin specific markup:
We need also to provide the events file, dracula.xml
<data wiki-url="" wiki-section="Vlad the Impaler Timeline">
    <event start="Dec 5 1431 00:00:00 GMT" title="Vlad born">
    Vlad the Impaler was born in November or December 1431.
    <event start="Nov 5 1436 00:00:00 GMT" title="Vlad enters the Dragon Order">
    In 1436 Vlad Dracul induces his 5 years old son into the order of the Dragon.
    <event start="Dec 5 1449 00:00:00 GMT" title="Vlad arrives at Suceava">
    After an unsuccessful attempt to seize the Valachian trone, Vlad the Impaler travels to his uncle's court in Moldavia.
<event start="Jan 7 1451 00:00:00 GMT" title="Envoy to Mehmed">
    Vladislav II Danesti sends a boyar as his envoy to the Otoman court, to tighten the ties with Mehmed II.
Here is how the timeline article looks like on mu{d}sings:

The timeline component has a very nice "buble" feature, where we can add additional information about the event. The bubble can have a link to a more lenghty article and discussion about the event.

The location of the article is configured via the wiki-url and wiki-section in the xml file.  We can imagine the wiki-url as the website and the wiki-section as the category for all the related articles.

There is a slight problem though: joomla default urls are ugly: and so on.

To solve this issue and be able to find the articles from the Discuss link, we need to activate the SEO feature of Joomla, which produces prettier URLs. Well, "That's okay, I knew this would happen But I was hopin' not today" :) .

To enable SEO friendly URL on Joomla we have to rename the htacess in the distribution to .htaccess. Mudsings is on iPage, on a LAMP account, so no problem here. Also we need to enable the SEO configuration via the control panel:

We have now another surprise: Joomla actually adds the article id to the URL:

Ugly! The answer is in this forum post:

 Add the below code in the end of "articles" fieldset (file: administrator/components/com/content/config.xml):
<field name="sef_advanced_link" type="radio" default="1" label="SefAdvancedMode" description="Remove Item ID from Content URL?">
<option value="0">JNO</option>
<option value="1">JYES</option>

Go to the Article Manager, open options and save. The article ID is gone !

Here is how the URL looks like now. Pretty, isn't it?

What is left to be done now is to configure the wiki-url and the wiki-section. Here we run into yet another problem:

SIMILE source code is tailord for MediaWiki. I didn't feel like installing and managing MediaWiki when Joomla offers a very nice content manager with a good discussion integration on the Kunena Forums.

Media Wiki replaces the spaces in the article name with underline while Joomla uses the dash. Fustian ! A little poking around in ten plugin's source code reveled where the underline is. Let's replace it with the dash and we can test !

Now... what else do you know about Dracula ?

Sunday, November 6, 2011

La donna รจ mobile...


... Qual piuma al vento...

In one of the previous blog entries I said I will not try to run Joomla 1.5 on Quercus, as it is yesterday's news. Well, I changed my mind :) I am happy I did as I found out many new things about Quercus and its relationship with PHP.

Here are several things one needs to take into account when attempting to install Joomla 1.5 on Quercus/Resin/Caucho

1. Static Variables

Quercus has a fancy way to treat the static variables. One cannot declare static variables inside functions as Joomla does all over the place. As Quercus translates to Java, it attempts to declare them as static at the class level. If you have several statics with the same name, as factory.php does, Quercus gets thoroughly confused and throws a stack overflow exception !

Joomla 1.5 needs to be fixed and any static variable declared inside a function must be transferred outside. For example:

static $apinstance;  
        function &getApplication($id = null, $config = array(), $prefix='J')

if (!is_object(self::$apinstance))
jimport( 'joomla.application.application' );
if (!$id) {
JError::raiseError(500, 'Application Instantiation Error');
self::$apinstance = JApplication::getInstance($id, $config, $prefix);
return self::$apinstance;
You will have to hunt all these instances and fix them. Quite painful.

2. Database connection

For some reason Joomla cannot pick up the database configuration from configuration.php. It picks up the database name but not the host/user name/password. One has to define the database connection as a resource in quercus:

Create a resin-web.xml under WEB-INF with the following contents:

<?xml version="1.0" encoding="UTF-8"?>
<web-app xmlns="">
<dispatch regexp="\.(php|gif|css|jpg|png|ico|js|html|htm|txt)"/>
<forward regexp="^/" target="/index.php?q="/>

  <database jndi-name="jdbc/mysql">
    <driver type="">
      <user>your user</user>

  <servlet-mapping url-pattern="*.php"

This will create a database resource for your database. You will give the database name in configuration.php as usual.

3. mbstring.language

mbstring.language must be defined in php.ini to avoid the warning below. Refer to resin-web.xml above for how to configure php.ini.

The value must be: mbstring.language=neutral

After these 3 aspects are fixed, one can attempt the installation. One problem here: if you are on Mac, the sample data button does not work, as the installation program assumes IE. You can pick up the SQL script, replace the table prefix and run it manually.

All these aspects fixed, Joomla 1.5 installs nicely on Quercus. It will probably take you way less time, as you'll not have to debug PHP via the PHP interpreter in Quercus, to realize that stack overflow actually means "Unable to load application" or "Application Instantiation Error". If you ever got the "Infinite loop detected in JError", it is the same thing. Something happened and the JApplication object cannot be instantiated. In this case Quercus couldn't create the static field "$instance". Some other time is the database...

And here is joomla on localhost:8080, under Caucho Resin/Quercus:

Time to go get some Fajitas. "Muta d'accento — e di pensiero" costed me almost the whole day ! :)

Saturday, November 5, 2011

There is more than one way to skin a cat


Note: no real cats have been hurt while writing this article :)

In one of my previous posts I showed how to update your Joomla/Drupal site using only your iPad. We tend to be away from our computers a lot :).

If you are on Amazon EC2 and have the luxury of ssh access here is how to install/update an Acquia Drupal site on the go.

There are three very important tools for the iPad, as I mentioned before, worth every penny:

1. iSSH - offers the ability to open ssh/telnet and VNC connections to remote computers.

2. Textastic - offers the ability to edit files on a remote machine while offering syntax coloring. While probably one could make it with Emacs or Vim, I would say Textastic is way more comfortable and also providing off-line editing capabilities.

3. MySQL - the iPad (almost) equivalent of phpMyAdmin
It offers the ability to run SQL queries against a configured database. The only iPad MySql client that actually works :)

In this article we will install the Aquia Drupal on Quercus. Follow the steps in this article to get Quercus up and running.

Here are the steps to configure the iPad tools.

1. Configure iSSH to connect to your Amazon EC2 instance

1. Email/DropBox the [key]. pem file you started the instance with.
2. General Settings/Configure SSH Keys/Import Keys.
3. Paste the contents of the .pem file in the text box.

Make sure you delete the e-mail or the DropBox file after you are done. If you are using e-mail, make sure you are using an ecrypted service like gmail.

2. Configure an iSSH connection
1. In iSSH choose "Add a configuration"
2. Turn on the "Use Key" option and select the key you set up at step 1.
3. Enter the VM ip adress and ec2-user as the user name
4. Select Ssh/shell as mode of connection

Save and test the connection. You should get a terminal window open.

Here are the downloads for Acquia Drupal (as of the date of this writing)

1. Aquia Drupal Core

Using iSSH, open a terminal to your Amazon EC2 instance.

$mv acquia-drupal- ../resin/webapps/ROOT/adrupal

2. Set up the database -

in iSSH

$mysql -u root -p
mysql> grant all privileges on *.* to 'yourfavuser'@'%' identified by 'yourpassword' with GRANT option;

In MySQL iPad application:

Create the database

Create the user

3. Start the Drupal installation program


Install Drupal in the usual way.

If you cannot get through the first screen most probably either the user name and/or password are incorrect or the user doesn't have the right privileges.

I'll let you discover how nice Textastic can be when it come to fixing your site :)

Friday, November 4, 2011

Someone has been busy last night...


I woke up at 4am the other morning after a great night sleep, all enthusiastic about Quercus and Drupal, eager for my next blog entry.

Fired up iSSH and surprise... My MDS VM dissappeared from under my feet. I was baffled, I actually put an outragous 50 cents an hour maximum price to prevent these occurences... Darn, for this price one could get a real computer not a meager micro-instance.

When I looked at the spot pricing it shot up to $10/hour. As in "I want everyone out of here, no matter how much it will cost me!" :)

I wonder what type of processing is worth 1000 times the regular price. Your guess is as good as mine.

In any case, after waiting for about 45 minutes to get a spot instance, with the Damocles's sword above my head that it can happen again, I decided to move my business on a different availability zone. The coward thing to do but really, if my application would be so important, i'd get a reserved instance.

Moving your VM to a different availability zone is straightforward: just start it there. If your VM has an attached volume though (see my MDS article) it is more complicated. You have to start the VM in the same availability zone as your volume. Which means you have to move the volume.

Amazon doesn't give you a direct way to do this, but here are the steps:

1. Take a snapshot of your volume
2. Create a new volume from the snapshot in the desired availability zone.
3. Start up your VM in the new availability zone attaching the new volume.

If you are in a hurry you can even snapshot your volume on your iPhone with the Cloud Manager application:

It sounds complicated, especially if you are starting it as a spot instance. Here is a script which will automate this for you: the spot request, waiting for the VM, attaching the volume, attaching the IP and tagging it.

Even if people get busy at night, one can still recover ! :)

Sunday, October 30, 2011

Cut on the cutting edge...

In one of my previous posts, There and back again... Ready for a new adventure I presented a short comparison between the Godaddy and the iPage infrastructure performance, based on a 25 concurrent users session of about 45 minutes, on accessing the home page of a vanilla Joomla installation.

This article will present the adventure of repeating the (almost same) test with Caucho/Quercus on the Amazon infrastructure.

My initial attempt was to install Joomla 1.7 under Quercus. Unfortunately it uses too many "cutting edge" PHP features/extensions and it is incompatible with Quercus.

The next step was to try version 7 of Drupal. It had less incompatibilities, but the elephant in the room, the PDO issue, made it a no go too.

After getting cut on the cutting edge I settled for Drupal 6. Joomla 1.5 reached its end of life, no reason to loose any time on it.

The purpose of the test is to see the performance differences in a load test on the home page of a vanilla Drupal installation. Here are the candidates:

1. Drupal installed under Caucho/Resin/Quercus on Amazon EC2

    The architecture:
         1. Microinstance with MySQL and Caucho Resin/Quercus
         2. Drupal

2. Drupal installed on the iPage account via the SimpleScripts facility

As the previous test showed there is a important difference between iPage and GoDaddy, I decided it was not worth to invest the $4.75 in testing GoDaddy again :)

The Drupal 6 installation on the Amazon EC2 instance went with no issues. Here are the steps:

1. Download/install the Oracle :D JDK
2. Download/install Caucho/Resin
3. Download/install Drupal 6

Start with the MDS template which explains how to configure a "persistent" database service.

1. Download and install the Oracle JDK
Caucho/resin must eventually compile the php translated files, so a JDK is necessary.

$chmod u+x jdk-6u29-linux-i586.bin

2.  Download/install Caucho/Resin
$ gunzip

Set JAVA_HOME to point to your new JDK installation:
$ JAVA_HOME=/data/jdk1.6.0_29

Start Caucho/Resin:
$cd /data/
$./ start

3. Download and install Drupal
$mv /data/drupal-6.22  /data/

Access the installation at: http://<your_ip>:8080/drupal-6.22/and follow the installation steps. You should see the first page for Drupal:

Caucho/Resin default installation comes with Quercus already installed and configured to serve the php files out of the box.

Running the tests. 

The tests were identical with the previous suite: access the home page with a ramp of 25 users within 15 minutes and keep the load for the next 30 minutes.

Here are the results. Quite interesting !

Quercus iPage
Test Plan

Data Throughput

Response Time

Test Stats


It looks like Amazon EC2 can give twice the throughput and almost half the response time iPage does, serving about 500 more transactions in the same amount of time. These results are with the vanilla versions of the Amazon instance, vanilla configuration of resin/caucho, the open source version and vanilla Drupal. From here it can get only better :) Now one could write fast a Drupal module, backed by a Java service ! Rapid development _and_ performance. Having your cake and eating it :)

I think I'll follow this train for a while to see where it would lead. Probably getting more "cuts on the cutting edge" in the process :D

Sunday, October 23, 2011

Joomla from the iPad (only)


One nice thing about Joomla is that one could work a site exclusively from the iPad. Here is a set of tools which can help in building and maintaining your website on the go.

Almot all hosting companies will offer a way to install Joomla in your hosting account. From there you need to install and configure extensions like templates, modules and components.

The biggest problem you will encounter is that no iPad browser can upload. So one has to go through some hoops to download and install extensions.

Joomla can install extensions in 3 ways:

1. Upload from the local drive
2. Upload from an expanded folder in usually the tmp folder of your installation
3. Upload from a remote zip file

If you know the location of the zip file and login is not required, the 3rd method works very well. If you received the file by e-mail for example or you need to download it, additional steps are required.

We will need a way to download the extension and upload it on the server. The trick here is to use no. 3 with yoursite.tld/tmp/

Textastic is for iPad what a FTP/ssh client is for your PC. And more. As in syntax coloring :) I think it is worth every penny.

Let's take the example of a template sent by e-mail. If you are still on iOS 4 you might need to go first through DropBox to get the archives on Textastic:

If you are on iOS5, Textastic will be offered as a choice. Unfortunately it crashes when I try to upload it directly, may be you will be more lucky :)

Choose DropBox to be sure and upload the extension to DropBox:

The next step is to transfer it to Textastic. Link your Textastic application with DropBox and transfer the file locally.

From Textastic transfer it to your website Joomla installation tmp folder:

Use the 3rd option to upload the extension:

This is it !

Well, it is kinda scratching your left year with your right hand, but after a couple of sites you will have a nice library of extensions to draw from in Textastic, ready to transfer on your new site and install.

May be iPad 5 will offer the ability to download and upload files as your PC does... Until then I hope this helps.

This post is written with Blogsy. My other blogging app, BlogPress is just crashing on iOS5 even after deleting and reinstalling, reconfiguring etc...

You might also find useful the PhotoPad application to slightly alter/crop your (blog) pictures.

Wednesday, October 19, 2011

And some things that should not have been forgotten...

... were lost.

And this is how I find myself configuring over and over again the Remote Systems connection on Eclipse. If you didn't try it it, maybe you should. Remember all those tools, Putty, WinSCP, JellyFissh, just ssh and so on ?

You got it all on Eclipse. It is tricky though, because not all the configuration is in the same place.

All the connections to Amazon EC2 are done through a key, and not user name and password. The key has a higher level of security and encryption then a simple password.

You specify the key pair on the instance start-up and Amazon will copy the key on the ec2-user account. This account has sudo privileges, allowing you to execute privileged commands. Amazon doesn't give access to the root account by default, which is a good thing.

The first step is to make sure you have the key you started your instance with in the .ssh folder on your Macintosh. You can follow the instructions here to set it up.

If you were curious how to run PHP code under a java application server, you already have Eclipse installed.

To set up access to an Amazon EC2 instance from Eclipse, you need to:

1. Set up the key in Eclipse
2. Create a SSH/Sftp Linux connection in the Remote systems view.

1. Set up the key in Eclipse

The key is set up on the General/Network menu in the Eclipse preferences. On Macintosh the preferences are accessed through the Eclipse menu.

Choose Eclipse->Preferences. Click on General->Network Connections->SSH2

Click on Add Private Key and choose the key you started your instance with.

2. Create a Linux connection on the Remote Systems view.

Choose Window->Open Perspective->Remote Systems Explorer

Ctrl->Click->New Connection

Make sure you choose Linux and not Unix. Most Unix instances on EC2 are Linux. The Linux connection type supports SFTP. The Unix connection type will use FTP.

Enter the IP address or the host name on the next screen and browse through the next screen in case you need to do any adjustments.

You will be able to access and edit your remote remote files and open ssh connections to your EC2 machine, all in the same place:

Syntax coloring, ssh console, remote file editing... what are we waiting for ? :)

And so things that should not be forgotten... are kept here for a fast reminder when needed.