How is beach sand created?

Beaches can be white, black, green, red and even pink. What creates those different colors? Why is some sand soft and fine, but other types feel rough? Where does beach sand come from, anyway?