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 to broad. 

Having said that we have an [excellent canonical Q&A][1] 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][2]. 


  [1]: http://serverfault.com/questions/212269/tips-for-securing-a-lamp-server
  [2]: http://serverfault.com/search?q=securing%20LAMP