For detailed and up-to-date information, including features by hardware model, please see Apple’s “Use the Energy Saver settings on your Mac” support page.
1. Select 'System Preferences' from the 'Apple' menu in the upper left-hand corner of the screen.
2. In the System Preferences window, click on 'Energy Saver'.
3. In the 'Energy Saver' panel, make sure the 'Prevent computer from sleeping when the display is off' and 'Wake for network access' boxes are checked.