Ananas, the original name of the fruit, comes from the Tupi (Brazilian) word for pine, nanas meaning "excellent fruit"; comosus is Latin for 'hairy, tufted' which refers to the stem of the fruit.
The English word pineapple originally meant what is now called a pine cone, and was used for the fruit because of its similarity to a pine cone.