In the question it says "a civilian" meaning some one with no titles. This means the president does not have to be in the military to be president. But once he is president he is in charge of the armed forces.
To serve as president, one must: be a natural-born U.S. citizen of the United States; be at least 35 years old; be a resident in the United States for at least 14 years.