Entanglement production and decoherence-free subspace of two single-mode cavities embedded in a common environment