It very much depends on what exactly you want.
For statically banning some particularly abusive /16 subnets, it is easiest to just install a firewall rule. I'd recommend shorewall for this, as it is much more user friendly than the raw stuff. Blacklisting 4-5 subnets magically reduces your noise ratio by 99%, it is amazing.
For dynamically banning script kiddies, simply installing fail2ban is a working solution that requires very little work.
Or, you could do the same dynamic banning yourself, but then you would need to do some bookkeeping (IP addresses change, so unless you unblock every now and then, you will eventually blacklist the entire internet!). A database is better suited than flat text files in such a case.
If you don't like dealing with a firewall because it feels like voodoo to you, you can still DENY in the .htaccess file. This will work "the same" for your php pages, but will be much less efficient, and won't stop someone from trying to exploit e.g. your SSH.