Recently it was shown that there is a unique Z4R symmetry for the MSSM which allows for the Yukawa couplings and dimension five neutrino mass operator, forbids the μ term and commutes with SO(10). This Z4R symmetry contains matter parity as a subgroup and forbids dimension four and five proton decay operators. We show how to construct string vacua with discrete R symmetries in general and this symmetry in particular, and present an explicit example which exhibits the exact MSSM spectrum, the Z4R symmetry as well as other desired features such as gauge-top unification. We introduce the Hilbert basis method for determining all D-flat configurations and efficient algorithms for identifying field configurations with a desired residual symmetry. These methods are used in an explicit example, in which we describe in detail how to construct a supersymmetric vacuum configuration with the phenomenologically attractive Z4R symmetry. At the perturbative level, this is a supersymmetric Minkowski vacuum in which almost all singlet fields (moduli) are fixed. © 2011 Elsevier B.V.