Speeding up phpMyAdmin
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.
BBC radio through Rhythmbox
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
Layered PNGs in GIMP
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.
Setting up PDT 1.x, Eclipse 3.3 on Ubuntu Hardy
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:
- 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).
- Update Eclipse to 3.3.x using its own build-in auto-update function. To do this:
- 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)
- 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.
- Select the most recent Eclipse 3.3.x version and then follow all of the installation instructions (will take a few mins).
- Exit Eclipse
- 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.
Zend Framework in Ubuntu 8.04
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.