We generally expect questions to be reasonably scoped. You can write whole books about securing servers, stacks etc. - that's the reason why your question was closed - it's way too broad.
Having said that we have an excellent canonical Q&A on securing a LAMP server which would be a good place to start. Once you've done that then you could also work your way through the Q&A in this search.