What does the writer of Ecclesiastes mean by the words "under the sun"? 

In this book of the Old Testament Wisdom Literature, a common phrase is "under the sun"—as in "There's nothing new under the sun."
The term appears some 30 times in Ecclesiastes, and refers to human existence without reference to God. Everything feels meaningless "under the sun."

Yet the writer is definitely not saying that life is meaningless (like the existentialist philosophers). Rather, life finds true meaning when lived in the presence of God.