Tech Support Cheat Sheet

Tech Support Cheat Sheet
Taken from xkcd

Apache mod_rewrite tips and tricks

So I was trying to solve a weird redirect issue: Request exceeded the limit of 10 internal redirects due to probable configuration error.

I found this site, which had quite alot of info.

One tip I really liked was:

Cache-Friendly File Names

This is probably my favorite, and I use it on every site I work on. It allows me to update my javascript and css files in my visitors cache’s simply by naming them differently in the html, on the server they stay the same name. This rewrites all files for /zap/j/anything-anynumber.js to /zap/j/anything.js and /zap/c/anything-anynumber.css to /zap/c/anything.css

RewriteRule ^zap/(j|c)/([a-z]+)-([0-9]+)\.(js|css)$ /zap/$1/$2.$4 [L]

Local development – multiple vhosts

As with alot of devs out there, I have a couple of virtual hosts setup. It is rather annoying to keep updating the /etc/hosts file. I came across “42foo: all the virtual hosts you need for your web development” which has helped alot. But this was not enough, the virtual hosts are still static, then I found “Dynamically Configured Mass Virtual Hosting“.

So now I have the following setup:

/etc/dnsmasq.conf

no-resolv
server=<DNSSERVER>
address=/.local/<DEVSERVERIP>
no-hosts

/etc/apache2/conf.d/multi_vhost (on the devserver)

# get the server name from the Host: header
UseCanonicalName Off

# this log format can be split per-virtual-host based on the first field
LogFormat "%V %h %l %u %t \"%r\" %s %b" vcommon
CustomLog /var/log/apache2/vhost_access_log vcommon

# include the server name in the filenames used to satisfy requests
VirtualDocumentRoot /var/www/%0/

<Directory /var/www/>
 AllowOverride All
 Order allow,deny
 Allow from all
</Directory>

Apache requires the mod_vhost_alias module to be loaded.

And this is it, all that is needed now is to have a symlink/directory in /var/www/ with the name of the virtualhost pointing to the document root of the dev site.

EG: /var/www/test.local -> /home/<user>/Development/test/webroot/

So now no more editing multiple files, all I need is to create a symlink and sorted :)

P.S. I did find that the Avahi daemon was causing issues see Bug #80900

To disable the Avahi daemon:

sudo invoke-rc.d avahi-daemon stop
sudo update-rc.d -f avahi-daemon remove

UPDATE: I needed to add the directory clause to multi_vhost as I needed to use .htaccess files ;)
UPDATE 2: There was also an issue with mod_rewrite (Request exceeded the limit of 10 internal redirects due to probable configuration error.) This was only happening to sites with a .htaccess. The solution was to add:

RewriteBase /

RE: Hating Microsoft

For those of you Microsoft Zealots out there read the following: Russell Coker: Hating Microsoft it might explain a few things ;)

Now STFU :p

Microsoft Tax– Howto get a refund

Was going through my rss feeds and found the following on Planet Ubuntu: http://simos.info/blog/archives/1000

I now can’t wait till I get a new PC :)

Hopefully this helps others out there who don’t need/want windows, there are other alternatives: http://distrowatch.com

Half-Gotee

To shave or not to shave

So for the last little while I have been growing a beard… :) Well Cecilia wants me to shave it, but I don’t really want to… :(

So I leave it to anyone who reads his, what should I do?

Half-Gotee

Phone update – Nokia 5800 XpressMusic

So, I’ve been using this phone for a while now, and it’s quite awesome… Well when using all the features the battery only seems to last about a day and a half, but that’s with WIFI and GPS on, so not too surprized…

The GPS and Nokia maps isn’t too bad, managed to get me to a couple of places I needed to go, one annoying thing though is that sometimes it wants me to take an offramp and then an onramp to the same hiway… *weird*

Still need to try get this phone to sync with my PC, just havn’t really had the time to play with it…

I really like the touch screen, and the multiple”keyboards” pity they only in qwerty format… and too small to use like a pc keyboard…

Well overall I think it was a great choise, now to find some decent logging software so I can contribute to openstreetmaps.org

Internet or lack thereof

So I found a nice internet speed tester… Dunno how acurate it is but it shows just how crap our internet is… :(

At home using iBust:

Speedtest Home

Speedtest Home

And at work using ADSL:

Speedtest Work

Speedtest Work

Both of these are supposed to be 1Mb/s lines (not 100% sure about work I think it’s actually a 4Mb/s line)

Just shows how bad the internet is here :(

Hopefully by 2010 as Telkom are advertising we will have better access…

New Phone – Nokia 5800 XpressMusic

So today I got my new Phone, after loosing my old one, and then sending my temporary one through the wash :(

First off, thank you and sorry Cecilia, I know that this has “messed” up the accounts :(

Offhand this is a fairly nice phone, just need to get used to it, will report more on it later…

MySQL group_concat not returning all data.

So working on a project for work, and it was not behaving as expected. I was selecting all the ID’s from a table that was linked to a couple of other tables, it turns out that it wasn’t returning all the id’s as expected as there is a limit on the amount of data that GROUP_CONCAT will return. MySQL Manual – GROUP_CONCAT

Well instead of using GROUP_CONCAT I’m now selecting the id’s individually, and this is now working.

Also there seems to be a limit on the number of items you can have in a IN clause: SELECT * FROM table WHERE field IN (xxx,xxx,xxx) so I’ve had to split these into 1000 peice chunks.

All seems to be working now after that, we’ll see how it goes… :)