This looks like a typical issue of a package having been installed from source rather than using Portage (which is the correct way of installing packages - you should never install directly from source). You should first check whether Portage has any record of PHP and Apache having been installed through it.
If installed through Portage rather than from source, both of these packages should return a record with an "Installed versions" version listed.
If Portage has no record of this, I suggesting finding some way of getting rid of the existing installation of Apache and PHP. This won't be trivial, since if installed from source, there's no quick and easy way of finding all the required files to remove. It may be safe to simply find the main binaries and general configuration files and try removing those. Once you've removed the existing installation, install PHP and Apache through Portage as follows:
emerge -av www-servers/apache
emerge -av dev-lang/php
See this existing question for full instructions on installing Apache and PHP with APC support.