The strong light-matter coupling attainable in optical cavities enables the generation of highly squeezed states of atomic ensembles. It was shown in [Phys. Rev. A 66, 022314 (2002)] how an effective one-axis twisting Hamiltonian can be realized in a cavity setup. Here, we extend this work and show how an effective two-axis twisting Hamiltonian can be realized in a similar cavity setup. We compare the two schemes in order to characterize their advantages. In the absence of decoherence, the two-axis Hamiltonian leads to more squeezing than the one-axis Hamiltonian. If limited by decoherence from spontaneous emission and cavity decay, we find roughly the same level of squeezing for the two schemes scaling as (NC)^(1/2) where C is the single atom cooperativity and N is the total number of atoms. When compared to an ideal squeezing operation, we find that for specific initial states, a dissipative version of the one-axis scheme attains higher fidelity than the unitary one-axis scheme or the two-axis scheme. However, the unitary one-axis and two-axis schemes perform better for general initial states.