Starting again my 9 miles challenge
9 miles should not require any changes to your diet, excluding extreme temperatures or excessively mountainous terrain. Your knee hurting is likewise not normal. Your bike may be a poor fit, or you may need to learn to use a lower gear: spinning the pedals faster, with less force required on each stroke.

Neither fatigue nor knee pain should be an expected outcome of a short, low-intensity cycling trip, particularly for someone of typical university age. If either of these persist, I would strongly recommend consulting with a physician.