Yes you can - the hardest part will be to track down where you have items installed. They tend to have files (configuration and other files) in subfolders as well (eg. /usr/share, etc.) The versions I have listed here are current as of May 7th, 2009. Future security updates may change the versions. For example to remove everything installed by fink/MacPorts it's just a matter of removing the /opt directory or use the respective
port command to remove it. If you have items installed in /usr/local, or /usr - backup first and then remove and test.
Default Installation: Apache 2.2.9 is installed in
Fink / MacPorts: Dependent on version but both install their representative ports into
Source: If you configured a different prefix then who knows but by default it installs into
Default Installation: 5.2.6 at
Fink / MacPorts:
Entropy: The most common pre-packaged PHP is available from http://www.entropy.ch and it installs PHP 5.2.9 into
Source: Depends on your prefix used when configuring but by default
If you're planning to install the pieces from the source I'd recommend looking at sticking with Mac Ports or documenting where you install items if compiling from the source. The added advantage to Mac Ports is that you can ignore trying to workaround or "fixing" Apple's presets for the version that comes with the OS itself. (eg. GD support in PHP).
The biggest limitation with rolling your own is that Apple does update the software it provides occasionally and that may conflict with a modification you've done. (If you'd heard of Apple "breaking" Perl on Mac OS X Server - they updated Perl for security reasons and if you had modified the system installed Perl it broke - something that a sysadmin is supposed to test for)
Alternatively if you're looking for development I'd recommend looking at MAMP or MAMP Pro - you've got a setup with all the pieces that runs on it's own.