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