We develop a theory for the interaction of multilevel atoms with multimode cavities yielding cavity-enhanced multiphoton resonances. The locations of the resonances are predicted from the use of effective two- and three-level Hamiltonians. As an application we show that quantum gates can be realized when photonic qubits are encoded on the cavity modes in arrangements where ancilla atoms transit the cavity. The fidelity of operations is increased by conditional measurements on the atom and by the use of a selected, dual-rail, Hilbert space. A universal set of gates is proposed, including the Fredkin gate and iSWAP operation; the system seems promising for scalability.