A real-time online ranging system is proposed using the frequency domain peak interval measurement method. By utilizing an NPR-locked, all-fiber, wide-spectrum erbium-doped femtosecond laser, a gain distribution with a center wavelength of 1560nm is obtained, with a repetition frequency of up to 14.54MHz, and then a femtosecond laser source with a spectral width of 38nm at -3dB can be obtained by adjusting its polarization state, which can improve ranging accuracy. By a combination of an upper computer system an all-fiber Michelson interferometer, real-time capture and processing of spectral interference data can be achieved, thereby realizing real-time acquisition of relative displacement distance. Experimental results show that within the coherence length, the measurable relative distance is around 2cm, and the measurement accuracy can reach 5μm.