A Henrico County middle school teacher who in February pleaded guilty to engaging in sexual acts with a 14-year-old student will serve 8 years in prison, according to court documents.