1. Modify the logind.conf configuration file
sudo vim /etc/systemd/logind.conf
or
sudo gedit /etc/systemd/logind.conf
2. Copy this line
#HandleLidSwitch=suspend
changed to
HandleLidSwitch=ignore
3. Restart the logind service
service systemd-logind restart