The word "how" has three primary meanings:
In what manner? Like, "How can I get across the river?" Answers might be to use a bridge or a boat. "How do I make a comment on Stackexchange?" Answers would explain what to type or what buttons to push.
In what quantity or to what extent? Usually (maybe always) accompanied by words indicating the thing being measured. "How far is it to Paris?" Someone might answer "20 kilometers". "How heavy is this box?" Someone might reply, "40 pounds" or "I don't know but I couldn't pick it up." "How long do I have to wait?" "About ten minutes." Etc.
In what status? "How are you feeling today?" That is, are you feeling well or are you feeling sick? "How is the battle going?" Is our side winning or are we losing?
Oh, perhaps I should add that there is a fourth meaning: "How" can be used as an intensifier or exclamation. But generally this is the same idea as one of the above three, just shifting from a question to an exclamation. "How tall you are!" "How far we have come!" "How the battle raged!"
As with any word with multiple meanings, you have to figure out which is meant from context. Usually only one meaning will make sense in context, though of course there are always cases where it could be ambiguous.
For example, some people say, "How are you doing?" as a greeting. The conventional answer is, "I'm fine, thank you" or "I'm fine. How are you?" A friend of mine liked to answer, "How am I doing what?" Yes, the joke got stale after the 300th repetition. But the idea was, the person asking meant "how" in the sense of "in what condition", are you well or are you ill? But he pretended to interpret it as "in what manner", like someone might ask "How are you doing this task?"
In your example, both "how"s are being used as intensifiers to indicate large extents or quantities. "How far" -- he had travelled very far. "How much" -- he wished very greatly.