The photoluminescence (PL) spectra of Mg-doped GaN on sapphire have been measured at 12K. The residual strain induced by the mismatch of the lattice constants and thermal expansion between GaN epilayers and substrates have been investigated by micro-Raman scattering and x-ray diffraction. Redshifts of the ultraviolet PL bands were observed in Mg-doped GaN after annealing in nitrogen ambient, which may be related to the carrier concentration and the strain in the epilayers. For heavily Mg-doped GaN films, the hole concentration in GaN, which shifts the PL peaks, is the dominant influence, whereas the strain is comparatively secondary.