miles was born in baltimore, maryland on may 4, 1804. he was a cadet at the united states military academy at west point from june 24, 1819, to july 1, 1824. he was commissioned a brevet second lieutenant in the 7th infantry regiment. nine years later miles was promoted to first lieutenant in 1833 and captain in 1836. he served as assistant quartermaster from january 16, 1839 to september 30, 1845. in 1846, he served in the mexican–american war. at the siege of fort texas he was cited for gallantry and "meritorious conduct" in the defense of fort texas and was promoted to the rank of major.