Speeding up phpMyAdmin

Posted 23:35, on 29/7/2010 in Web, Ubuntu

Here's a quick tip for speeding up phpMyAdmin when using it on a remote server. A big drain on rendering speed for the app seems to be the sheer number of theme related requests (images and stylesheets) the browser makes on every page load. An easy way around this is to use the Apache module mod_expires to send an expires header with these files, which tells the browser not to bother requesting them again for a set period. This cuts down the total requests by about 90%.

Firstly, make sure mod_expires is enabled:

sudo a2enmod expires
sudo apache2ctl restart

then open the phpMyAdmin Apache configuration file (by default in located at /etc/apache2/conf.d/phpmyadmin.conf) in your text editor of choice. You'll see an IfModule block which sets up some php values:

<Directory /usr/share/phpmyadmin>
    Options FollowSymLinks
    DirectoryIndex index.php

    <IfModule mod_php5.c>
        AddType application/x-httpd-php .php

        php_flag magic_quotes_gpc Off
        php_flag track_vars On
        php_flag register_globals Off
        php_value include_path .
    </IfModule>
</Directory>

insert the following mod_expires block below the existing </IfModule>:

    <IfModule mod_expires.c>
        ExpiresActive On
        ExpiresByType image/gif "access plus 7 days"
        ExpiresByType image/jpg "access plus 7 days"
        ExpiresByType image/png "access plus 7 days"
        ExpiresByType text/css "access plus 7 days"
        ExpiresByType application/javascript "access plus 7 days"
    </IfModule>

which should leave you with this:

<Directory /usr/share/phpmyadmin>
    Options FollowSymLinks
    DirectoryIndex index.php

    <IfModule mod_php5.c>
        AddType application/x-httpd-php .php

        php_flag magic_quotes_gpc Off
        php_flag track_vars On
        php_flag register_globals Off
        php_value include_path .
    </IfModule>

    <IfModule mod_expires.c>
        ExpiresActive On
        ExpiresByType image/gif "access plus 7 days"
        ExpiresByType image/jpg "access plus 7 days"
        ExpiresByType image/png "access plus 7 days"
        ExpiresByType text/css "access plus 7 days"
        ExpiresByType application/javascript "access plus 7 days"
    </IfModule>
</Directory>

Restart Apache (sudo apache2ctl restart) so the changes take effect.

What this does is tell Apache to send an expires header of 7 days into the future for all image, CSS and javascript files within phpMyAdmin. The initial request after the restart will be as before, but after that the browser knows that the files it got back are good for 7 days, so on subsequent requests it will only request the HTML page. You should see a noticeable speed improvement.

Normally when using mod_expires you would use a much longer expire time than 7 days, but this way if a future phpMyAdmin update does change these theme files you're less likely to get caught out.

Comments (1)

BBC radio through Rhythmbox

Posted 19:50, on 20/7/2008 in Ubuntu

Mainly for my own reference: It's possible to stream BBC radio through the 'radio' part of Rhythmbox (and this is preferable to the iPlayer because of Ubuntu's slightly flaky flash support). 

To use it just add a new 'Internet radio station', e.g. Radio 1 is: mms://wmlive-acl.bbc.co.uk/wms/radio1/radio1_nb_e1s1

Comments (2)

Layered PNGs in GIMP

Posted 21:16, on 6/5/2008 in Ubuntu

I quite often receive website creative supplied in PNG format, particularly from our main designer who uses Macromedia Fireworks. Fireworks saves these by default with layers, which can be useful when converting layouts into HTML/CSS, but I never understood why these layers were gone when I opened the file in the GIMP.

It turns out, the reason is because the PNG format doesn't support layers! The PNG spec does allow files to contain some 'extra data', which is apparently where Macromedia stores the layer information (in an apparently closed format nothing else can read). So much for the 'portable' network graphics format.

Comments (0) Tags: png, gimp

Setting up PDT 1.x, Eclipse 3.3 on Ubuntu Hardy

Posted 13:03, on 3/5/2008 in Ubuntu

Not quite convinced by PHP under Netbeans, I decided to go back to the PDT plugin for Eclipse for my PHP development. Unfortunately setting this all up is much more complicated than it should be, since the current release version of PDT requires Eclipse 3.3+, but the latest version in the Ubuntu repositories is 3.2.2.

There are alternative ways to install this of course, the PDT site offers an all-in-one package, or you can download Eclipse 3.3 from eclipse.org, and go from there. However I've never had too much luck with these.

So here's how to get it working:

  1. Install the latest version of Eclipse from the repositories (you can do this either via. Applications > Add/Remove, via. Synaptic or via. the command line).
  2. Update Eclipse to 3.3.x using its own build-in auto-update function. To do this:
    1. Open a terminal window and run Eclipse as root - sudo eclipse (this is important as otherwise your update will fail when it tries to overwrite some of the root-owned core files)
    2. Add some new update sites which contain the 3.3 features (I used the list in this blog post), you can either add them manually or import from the from the supplied XML file.
    3. Select the most recent Eclipse 3.3.x version and then follow all of the installation instructions (will take a few mins).
    4. Exit Eclipse
  3. Install PDT. Run Eclipse normally (not via. sudo), you should get the 'Europa' splash screen, which will confirm that you're running version 3.3.x. Help > Find and install updates etc. Select PDT and its dependencies, and install.

et. voila.

Hopefully the next Ubuntu release will include an Eclipse update, which will make this process a lot easier.

Comments (0) Tags: pdt, eclipse

Zend Framework in Ubuntu 8.04

Posted 14:42, on 27/4/2008 in Web, Ubuntu

Update: The packaged version of Zend Framework is currently quite out of date (5 versions behind the current release at the time of writing), so I would recommend grabbing the latest release from http://framework.zend.com/ instead of installing using the method below.

With the release of Hardy, the Ubuntu repositories now include a package for the Zend Framework, so you can have just one copy of the library on your server that is automatically updated. To install and use this:

sudo apt-get install zend-framework

then add it to the include_path for your app, in a .htaccess file:

php_value include_path '.:/usr/share/php/libzend-framework-php'

you can then require in Zend Framework classes as you need them, or use the Zend autoloader to pull them in automatically when instantiated.

Comments (0) Tags: php, zend framework

External articles that may be of interest:

Rasmus - PHP Performance

Full video of a talk Rasmus gave at Digg HQ on PHP performance. After a brief look at PHP 5.3's new features he sets about improving the performance of an out-of-the-box Wordpress installation.

Adobe releases 64-bit flash player for Linux

Adobe have released an alpha of their 64-bit flash player for Linux (I believe this is the first 64-bit player they've done on any platform, it's not available for Windows or Mac yet). And it works great. It may be an alpha but so far I've found it considerably more stable than the released 32-bit wrapper version. It also uses considerably less CPU power. Easy installation instructions via. this blog entry.

MS Office in the browser

The most interesting thing about this announcement is that MS say the system will work in Firefox and Safari as well as IE. The Microsoft of 10 years ago would have used proprietary IE only code and used it as a way to leverage IE market share.

The Future of Advertising, Branding, Media and Communications

Video of a very interesting talk by Gerd Leonhard on the future of the media industry, and content on the Internet.

Future of web browsing from Mozilla Labs

Some interesting ideas about how web browsing might look in the future (watch the first video).