I have found that you need a break midway in the ride. When I ride with a group we go about half way, stop and have either coffee or lunch, and then continue the rest of the way. A 20-30 minute stop is enough that you can increase your mileage.

If you are going uphill, just stop and get off the bike for a minute and then get back on. I think it interrupts the lactic acid build up and you won't need to walk the bike.

The distance you can go is also affected by how many times you stop to take a brief rest, and how fast the pace is. If you never stop and the pace is faster than what is natural to you, you will get really tired. For beginners, 10-12 miles/hour is fast enough. 14-16 will tire you out. A stop at the top of a hill also helps. Eventually, you will need fewer stops and can go faster and can last for a longer distance.

Be sure to drink enough water and bring some good quality snacks (carbs and protein).