Running a Mac Remotely Over a LAN
You can prevent the Mac from sleeping in the Energy Saver preferences panel. There are a few options, but if you want to simply keep it awake the either:


Dragging the Computer sleep slider to Off.
Checking Prevent computer from sleeping automatically when the display is off.


You can find more options and details in Apple’s Support Document.