The writing of Old Testament books actually began around the 1660s B.C. when Job penned the work named after him. Sometime later Moses wrote the first five manuscripts we commonly find in the Bible during the period the children of Israel wandered the wilderness for forty years after the Exodus.
The prophetic books of Ezekiel and Daniel were written in Babylon. Obadiah was penned in Edom, as was Job. Esther authored the section named after her in Persia. The remaining books were all recorded in the land of Israel.
The books of the Old Testament underwent five stages or periods of canonization (the process by which a set of Bible manuscripts are considered inspired by God and authoritative). The first stage was under the direction of Moses who, before he died, authorized the first five major sections or books of Scripture (Genesis, Exodus, Leviticus, Numbers, and Deuteronomy, see Deuteronomy 31:9, 24 - 26).
The second phase of canonization of the Old Testament occurred under the rule of King David and Solomon, who wrote the books of Psalms, Proverbs and the Song of Solomon. According to "Restoring the Original Bible" by Ernest Martin, "the only reason for adding certain literature to the already existing documents of the Law was the establishment of the permanent Temple . . ." (chapter 12).
The third phase of canonizing Bible books occurred under the righteous King Hezekiah of Judah (who ruled from 715 to 686 B.C.). He set out to restore the correct worship of God (2Chronicles 29 - 31), especially at the temple in Jerusalem, after many years of neglect. According to Martin, Hezekiah brought up-to-date the canonical literature used in the restored Temple.
The fourth stage of canonization occurred during the reign of King Josiah, who ruled the Kingdom of Judah from 640 to 609 A.D. The final and greatest phase of canonization of Old Testament books took place under the prophet Ezra and the Great Assembly.
In regard to the New Testament, the books of Matthew, Mark, Luke, most of the gospel of John, the first twelve chapters of Acts, plus James and Jude were recorded in the land of Israel. Luke wrote chapters 13 through 15 of Acts somewhere along the route of Apostle Paul's first missionary journey. He recorded chapters 16 to part of 18 near Corinth, finished 18 to chapter 21 near the region of Ephesus, and then completed his book in the city the Rome.
It was at or near Corinth that the books of Romans, plus the first and second epistles to the Thessalonians, were written. Paul created the epistles of 1Timothy and Titus in Nicopolis and the epistle to the Galatians in Syrian Antioch. In the capital city of Rome were recorded the epistles to the Ephesians, Philippians, Colossians, Hebrews, 2Timothy, and Philemon.
It was in the chief city of Asia Minor, Ephesus, that the books of 1, 2 and 3 John, in addition to the two epistles to the Corinthians, were recorded. 1 and 2 Peter was authored in the region of ancient Babylon. The apostle John not only completed his gospel but also recorded the prophetic vision known as Revelation from the island of Patmos, which is located in the Aegean Sea.
Including Job, nine Bible books were completed before 1000 B.C. The remaining part of the Old Testament, with the exception of Malachi, was put in a written form between 1000 and 500 B.C. It took a much shorter time to compose the New Testament. The span of time from the first manuscript written in 35 A.D. (the gospel of Matthew), to the last one completed in 95 A.D. (Revelation), is only sixty years.