Install required packages on Gentoo

Modify portage configuration

# File: /etc/portage/package.use

# MySQL
dev-lang/php mysql gd apache2 truetype cli pcre xml zlib

# postgreSQL
dev-lang/php postgres gd apache2 truetype cli pcre xml zlib

# SQLite
dev-lang/php sqlite gd apache2 truetype cli pcre xml zlib

Install Apache and PHP with emerge

$ sudo emerge -v php

## You could have a cup of coffee from now, it'll take a little bit of time ;)

Enable apache to the default runlevel

# rc-update add apache2 default

Then restart Apache

# /etc/init.d/apache2 restart