I don't think you're going to get a cheap optical sensor at the distances required.
Linear optical usually relies on glass scales, which is going to be expensive at the lengths you're looking for, and I'd say the accuracy will be wasted.

It's probably worth having a look at Heidenhain magentic tape system - https://www.heidenhain.co.uk/en_UK/p...near-encoders/