Residual stresses are generated in the process of straightening and side-straightening of machine tool linear guideway, which affects the accuracy and service life of the guideway. In this study, the residual stress control method and optimization design of machine tool linear guide rail in the process of straightening and side-straightening are developed. Combining ANSYS finite element analysis and digital image correlation method for stress measurement, NSGA-II algorithm is used to construct a multi-objective optimization model. The experimental results show that the error between the stress measurement based on digital image correlation method and the finite element simulation results is within ±10%, which verifies the accuracy of the calculation model. The optimized process parameters of straightening stroke of 2.417 mm and grinding depth of 27.14 μm reduce the transverse residual stress of the guideway from 100 MPa to less than 15 MPa, and at the same time achieve the optimal combination of straightness error of 0.109 mm and roughness error of 2.62 μm. The study proves the effectiveness of the proposed residual stress regulation method in the process of positive and lateral straightening of linear guideway of machine tool, which provides theoretical support for improving the machining accuracy and performance of the guideway.