Q:

How does aptitude determine what version of a package/application to install?  i.e. Apache 2.2 vs 2.4

So I wasted several days dealing with a lame Apache2 bug that was fixed in Februry 2012.  I couldn't figure out why I was experiencing the bug still until I discovered my version Apache2 was a 2.2.x version even thought I built up the entire server from scratch Debian 6 on Nov 30, 2012.  For some reason aptitude -install apache2 pulled 2.2.x instead of 2.4.x. 
I wish I had known not to assume aptitude will pull the latest stable build.  Can anyone shed some light on how the repositories are managed and why aptitude would be pulling from the older maintained infrastructure instead of the 2.4.x infrastructure?  Also, how would I specifically get aptitude to pull 2.4.x and how can I help myself avoid problems like this in the future? 

A:

Aptitude will always install the newest version available in repositories (except in some special cases like pinning, or when directed to install an older version specifically). 
The Debian family of Linux distributions (as well as the Red Hat family) test one specific version of a given software package for a given OS release (in your case, Debian 6 with Apache 2.2.16) and keep it at that version for the entire release for the sake of stability and configuration compatibility, backporting in any security or important bug fixes. 
So, apt installed the newest version of the apache2 package in the repository, which is the version that was tested with that OS and is offered in the Debian 6 repository.   If you need 2.4 for some specific reason, you should be able to find a third party repository that offers a package for it.