When you are sentenced to serve time in prison by a court, they are allowed to put you in any prison that has space for you. This means that you may be sent to a prison that is far away from everyone that you care about. You will not typically be sent overly far away since prisons often feel that contact with family is good for the rehabilitation of an individual.
After you have spent a few months in a prison, you are allowed to ask for a prison transfer. Most commonly a transfer will only be allowed if you can show that one is truly necessary. Family and friends can write to a Prison Governor after a prisoner applies for a transfer to show their support of the transfer. It also may be helpful to get notes from doctors or teachers explaining why a transfer would benefit the family.