I moved my Drupal web server from Ubuntu to Gentoo.
It was quite a bear getting the correct use flags set for Drupal.
The following are the use flags that you need for Drupal to work properly:
apache2 cli cgi gd session sockets pcre php postgres xml xmlrpc xsl
* Note: you might not need xmlrpc or xsl, but I was getting pretty tired of recompiling.