I do, in fact, that's primarily the reason for me jumping over to the Linux side of things (from Windows). I used to run this Internet cafe/gaming shop and got tired of having my WinGate (!) gateway getting DoS'd all the time. Hence the jump to Linux.
In those times, the built-in ipchains program helped me configure the Linux gateway/firewall as my main route to the Internet. Since then, ipchains has been renamed to iptables, and most recently that has been replaced by 'firewalld' (at least on Fedora, Red Hat Enterprise Linux and it's clones like the CentOS).
It is very tedious, however, you are able to fine-tune your firewall rulesets to your liking, with basics such as port blocking, allowing/blocking IP addresses to go in/out your local area network, specifying protocols to allow/block and doing NAT for your hosts sitting behind your Linux firewall.
Old PCs are always a good way to practice Linux on, just make sure you set it up without the complete GUI and just have the fundamentals installed. By default, iptables/firewalld should be available on newer versions of Fedora/RHEL/CentOS. I'm not well-versed in Ubuntu but I would imagine they'd still have iptables by default.
iptables - https://www.netfilter.org/
firewalld - https://firewalld.org/
As always, Google is your friend (also feel free to ask here).
What exactly did you need help with regarding LAMP?