Shirley is a town in Middlesex County, Massachusetts, United States. It is approximately fifty miles west-northwest of Boston. The population was 7,211 at the 2010 census. The town has a well-preserved historic New England town center.It is home to the Massachusetts Correctional Institution – Shirley, a medium-security state prison. The remains of a Shaker village have been preserved within the grounds of the prison.