The following is from "Multiplicative number theory I: Classical theory" by Hugh L. Montgomery, Robert C. Vaughan:
I understand everything in the proof except for:
How $m' \equiv n'$ (mod $d$)?
I tried every elementary rule I knew but failed. For example I concluded that $m' \equiv n'$ is true (mod $d_1$) but i can't conclude the same one for mod $d$.

Note that $d=d_1d_2$ with $(d_1,d_2)=1$. We have $m'\equiv n'\pmod{d_1}$ and $m'\equiv 1\equiv n'\pmod{q_2}$ and therefore $m'\equiv n'\pmod{d_2}$. Now the congruence is also true modulo $d=d_1d_2$ by CRT.