Step 1: Unplug your server from the ethernet
Step 2: Make a complete regular backup, as you usually do (if that's a network backup, you may need to plug it into a private network to do this)
Step 3: remove the hard disc and keep it for forensics
Step 4: Replace the HD, reinstall the OS, and make REALLY sure that you haven't accidentially restored any untrusted binaries when you restore.
Doing the restoration is the hardest part- you have to make TRIPLE sure that you aren't accidentally restoring any trojan'd binaries that were modified by the attacker.
Your best bet is to remove all executable content (inluding PHP of course) from the restore and replace it from your development server / source code area, recompilng anything as necessary
Once you're sure that your machine is clean, then you can investigate how to fix the hole the attacker used.
Mark