I am always forgetting how to do this,which is annoying as it is such a usefull command.
You can also use tasksel, but that often requires installing Tasksel first, and for a server install, I like to install only what I need!
Anyway, the command to install PHP, Mysql and Apache on ubuntu is:
sudo apt-get install lamp-server^