"All the world's a stage" is the phrase that begins a monologue from William Shakespeare's pastoral comedy As You Like It, spoken by the melancholy Jaques in Act II Scene VII Line 138. The speech compares the world to a stage and life to a play and catalogues the seven stages of a man's life, sometimes referred to as the seven ages of man.
All the world's a stage,
And all the men and women merely players;
They have their exits and their entrances,
And one man in his time plays many parts,
His acts being seven ages. At first, the infant,
Mewling and puking in the nurse's arms.
Then the whining schoolboy, with his satchel
And shining morning face, creeping like snail
Unwillingly to school. And then the lover,
Sighing like furnace, with a woeful ballad
Made to his mistress' eyebrow. Then a soldier,
Full of strange oaths and bearded like the pard,
Jealous in honour, sudden and quick in quarrel,
Seeking the bubble reputation
Even in the cannon's mouth. And then the justice,
In fair round belly with good capon lined,
With eyes severe and beard of formal cut,
Full of wise saws and modern instances;
And so he plays his part. The sixth age shifts
Into the lean and slippered pantaloon,
With spectacles on nose and pouch on side;
His youthful hose, well saved, a world too wide
For his shrunk shank, and his big manly voice,
Turning again toward childish treble, pipes
And whistles in his sound. Last scene of all,
That ends this strange eventful history,
Is second childishness and mere oblivion,
Sans teeth, sans eyes, sans taste, sans everything.
The comparison of the world to a stage and people to actors long predated Shakespeare. Juvenal, the ancient Roman poet, wrote one of the earliest versions of this line in his “Satire 3”: “All of Greece is a stage, and every Greek’s an actor.”  Richard Edwards' play Damon and Pythias, written in the year Shakespeare was born, contains the lines, "Pythagoras said that this world was like a stage / Whereon many play their parts; the lookers-on, the sage". When it was founded in 1599 Shakespeare's own theatre, The Globe, may have used the motto Totus mundus agit histrionem (All the world plays the actor), the Latin text of which is derived from a 12th-century treatise. Ultimately the words derive from quod fere totus mundus exercet histrionem (because almost the whole world are actors) attributed to Petronius, a phrase which had wide circulation in England at the time.
I hold the world but as the world, Gratiano;
A stage where every man must play a part,
And mine a sad one.— Act I, Scene I
In his work The Praise of Folly, first printed in 1511, Renaissance humanist Erasmus asks, "For what else is the life of man but a kind of play in which men in various costumes perform until the director motions them off the stage."
Likewise the division of human life into a series of ages was a commonplace of art and literature, which Shakespeare would have expected his audiences to recognize. The number of ages varied: three and four being the most common among ancient writers such as Aristotle. The concept of seven ages derives from mediaeval philosophy, which constructed groups of seven, as in the seven deadly sins, for theological reasons. The seven ages model dates from the 12th century. King Henry V had a tapestry illustrating the seven ages of man.
According to T. W. Baldwin, Shakespeare's version of the concept of the ages of man is based primarily upon Palingenius' book Zodiacus Vitae, a school text he would have studied at the Stratford Grammar School, which also enumerates stages of human life. He also takes elements from Ovid and other sources known to him.