Preventing the use of reverse shells once installed is very difficult, so the best way to avoid having a reverse shell installed in the first place is to make sure your server is not susceptible to initial attacks against vulnerabilities such as RCE, LFI, RFI, and SQLi. And the best way to do that is to include vulnerability checks in the software development lifecycle through the use of DAST and SCA tools with proper vulnerability management.
Find out how to use Invicti to prevent web vulnerabilities.