A gunman opened fire at the Teotihuacán archaeological site outside Mexico City before killing himself, the authorities said.