Well assuming that you're not that fit to start with it's probably best to quite a lot of base level indurance type training to start with. So probably do something like 2-4 rides per week at a low intensity for about 1-2 hours in length. Careful not to over do it – if you feel knackered don't go out till the next day, equally if you feel good, get out there.
After doing this for a couple of week, you can start upping the intensity a little bit, perhaps adding in some hills, or doing some sprints. You could try going fast for 5 minutes, followed by going slow for 5, and then repeating another 2 times.
After a while you could start setting yourself targets, e.g. I used to be able to get round a local circuit in 1hr15 but now I can do it sub-1hr and that was a big target to me to meet.
The best advice is to ride more, but its maybe a bit easier to do this if you can find some other people to ride this. Also riding in different places helps to keep things interesting. Likewise a mix of mountain biking and road riding can help.