The decision was announced by CAF President Issa Hayatou, after being voted on by the federation's executive committee in Cairo. Gabon beat Ghana and Algeria, who have both competed for hosting the cup.
This will be Gabon's second time to host the cup, having co-hosted it with Equatorial Guinea in 2012.
A draw for the cup's first round landed Egypt in group number 7, with Nigeria, Chad and Tanzania.
Nigeria ranked the 41st worldwide on the FIFA's March Chart, while Egypt ranked the 58th, Tanzania the 100th and Chad the 148th.
Egypt has won the cup more than any other nation, holding the title seven times.