Large-scale quantum computation is currently a hot area of research. The scalable quantum computation scheme with cavities originally proposed by Duan and Kimble (Phys. Rev. Lett., 92 (2004) 127902) is further developed here to operate in the intermediate coupling region, which not only greatly relaxes experimental demands on the Purcell factor, but also eliminates the need to consider internal trade-off between cavity quality and efficiency. In our scheme, by controlling the reflectivity of the input single-photon pulse in the cavity, we can realize local atom-photon and nonlocal atom-atom controlled phase-flip (CPF) gates. We also introduce a theoretical model to analyze the performance of our scheme under practical noise. Furthermore, we show that the nonlocal CPF gate can be used to realize a quantum repeater.