Ketil Froyn's blog

Main blog

Sun, 11 Apr 2010

Optimizing LAMP - the Linux Apache MySQL PHP stack - for speed, without touching any application code


There are a bunch of pretty easy things you can do to optimize your website for speed, improving the user experience and scalability of your website - without even touching your code!

This is Ketil's checklist of easy optimizations that will probably give your site a healthy speed boost:

  1. Don't let MySQL do a DNS lookup for every single connect from the webserver to the SQL server. Avoid this by adding the following option to the [mysqld] section of my.cnf:
    skip-name-resolve
    Make sure to always use IP-addresses in the GRANT command if you do this.
  2. Compiling the php script before execution can take hundreds of milliseconds - for every hit to your webserver. Install and enable PHP APC on your webserver to cache the compiled code, avoiding compilation delays for every access. You don't need to write any code to use this, even though APC can be used for other sorts of caching as well
  3. Browsers need to download and parse css and javascript files before showing anything to the user. Speed up the download by using HTTP level compression. Install and enable the headers and deflate modules on your webserver (deflate is usually already enabled), and make sure your css and javascript files also get compressed with this configuration in deflate.conf
    <IfModule mod_deflate.c>
            AddOutputFilterByType DEFLATE text/html text/plain text/xml
            AddOutputFilterByType DEFLATE application/xhtml+xml text/javascript text/css application/x-javascript application/javascript
            BrowserMatch ^Mozilla/4 gzip-only-text/html
            BrowserMatch ^Mozilla/4\.0[678] no-gzip
            BrowserMatch \bMSIE !no-gzip !gzip-only-text/html 
            Header append Vary User-Agent env=!dont-vary
    </IfModule>
    
  4. Let browsers cache static files for up to a month. Install and enable the expires module on your webserver, and add a config something like this to your virtualhost config to let browser cache images for up to 1 month:
            ExpiresActive On
            ExpiresByType image/gif "access plus 1 month"
            ExpiresByType image/jpeg "access plus 1 month"
            ExpiresByType image/jpg "access plus 1 month"
            ExpiresByType image/png "access plus 1 month"

For further improvements, some more advanced, please check back for the next posting on this subject.

-Ketil



posted at: 15:16 | path: /2010/04 | permanent link to this entry

Fri, 09 Apr 2010

DRAC5 Console Redirection Plug-in on Ubuntu 9.10


I'm in charge of some Dell servers, but after installing Ubuntu 9.10 on my laptop I've been unable to get the Dell Remote Access Controller 5 console redirection plugin working. It just kept dying with the error message "Digital Video Viewer 2.2.0.3 could not be installed because it is not compatible with Firefox 3.5.8.". So to get it working, I had to jump through the following hoops:

  1. Install firefox 3.0 on ubuntu 9.10
  2. Run firefox 3, connect to DRAC and install the plugin
  3. The plugin assumes you are using the default profile, which was wrong in my case. When I started it, nothing happened! To fix it, I installed ghex and edited the file $HOME/.mozilla/firefox//extensions/{975F5C72-BB6D-11DD-8236-0DA656D89593}/plugins/librac5vkvm.so. Search for '*.default' and replace it with an equally long wildcard that matches your profile directory. I replaced it with '????*.ff3'. After replacing it should look something like this:
    ~/.mozilla/firefox/????*.ff3/extensions/{975F5C72-BB6D-11DD-8236-0DA656D89593}/videoviewer

Now I finally have console access again!

Still not working for you? Remember to upgrade the RAC firmware version to at least 1.45 (09.01.16)



posted at: 02:42 | path: /2010/04 | permanent link to this entry

Installing Firefox 3.0 on Ubuntu 9.10 Karmic Koala


I got stuck needing an older version of firefox on Ubuntu to run a legacyi firefox plugin. It can also be useful for web developers needing to test their pages in older browser versions. This is how I installed Firefox 3.0 on Ubuntu 9.10:

  1. Download source:
    wget ftp://ftp.mozilla.org/pub/mozilla.org/firefox/releases/3.0.18/source/firefox-3.0.18-source.tar.bz2
  2. Install necessary packages. From System -> Administration -> Synaptic Package Manager, choose:
    build-essential
    libx11-dev
    libdbus-1-dev
    libidl-dev
    xserver-xorg-dev
    libxt-dev
    pkg-config
    (You may need more, I've installed other dev packages before)
  3. Unpack the source archive, and compile:
    tar xvfj firefox-3.0.18-source.tar.bz2
    cd mozilla
    ./configure --prefix=$HOME/ff3 --enable-application=browser --disable-crashreporter
    make
    make install
  4. Before running normally, start firefox with the profile manager and create a new profile for the old version of firefox, eg 'ff3':
    firefox -ProfileManager
  5. Install some necessary plugins (flash and java) where firefox will find them:
    mkdir $HOME/.mozilla/plugins
    cd $HOME/.mozilla/plugins
    ln -s /usr/lib/mozilla/plugins/flashplugin-alternative.so
    ln -s /usr/lib/jvm/java-6-sun-1.6.0.15/jre/lib/i386/libnpjp2.so
  6. Run firefox 3.0 with your new profile:
    $HOME/ff3/bin/firefox -P ff3

I tried the same with Firefox 2, but the build failed:

wget ftp://ftp.mozilla.org/pub/mozilla.org/firefox/releases/2.0.0.9/source/firefox-2.0.0.9-source.tar.bz2
tar xvfj firefox-2.0.0.9-source.tar.bz2
cd mozilla
./configure --prefix=$HOME/ff2 --enable-application=browser --disable-crashreporter
make
(compilation failed on my computer)



posted at: 02:28 | path: /2010/04 | permanent link to this entry