Jul 28, 2010

Installing VirtualBox guest additions in a Debian guest

Heres' how I got VirtualBox guest additions installed in a Debian guest.

First you have to install the Linux kernel headers, gcc and make, which can be done with this one-liner (run as root):
apt-get install linux-headers-`uname -r` gcc make

Then mount the guest-additions by clicking "Devices" + "Install guest additions" on the VirtualBox menu:















Shortly after, a drive will mount on the desktop containing the guest additions:









open a terminal and, as root, run the appropriate installer for your system, like f.x:
sh /media/cdrom/VBoxLinuxAdditions-x86.run

Now the guest additions are built and installed. When it's done, just restart the virtual machine.

Apr 28, 2010

If connections from remote clients to MySQL are slow

MySQL attempts name resolving on remote connection and that can adversely impact performance.

I had a case where a client app written in Visual Basic, connecting via ODBC to a MySQL server running on Linux. It was abnormally slow. The VB app aquired a fresh connection upon every query and each query then took exactly 10 seconds to complete.
This smelled like a timeout scenario to me so I suspected a DNS lookup was taking place.

Adding the following config option to my.cnf solved the problem:
skip-name-resolve
It prevents MySQL from doing a DNS lookup of the remote clients IP adress.
Note that by using this option you can only use IP adresses (or "localhost") in the MySQL grants table.

More info at the MySQL site here:
http://dev.mysql.com/doc/refman/5.0/en/dns.html

Mar 19, 2010

Check all your PHP source files for errors

To recursively check all PHP source files at a given location:

find -name *.php -exec php -l -f {} \; | grep "Parse error:"

This shows which files have syntax errors, like this:
Parse error: syntax error, unexpected ';' in xyz.php on line 206