@CodeNinja
in this case, DMZ + WAF will be your good friend
something like this that I can suggest:
• OS: Debian 10.x (Buster) 64bit
• Apache Worker, factory package
• Mod Security apache module with OWASP rules, factory package
• PHP-FPM 7.3 or rather 7.4 if it goes with everything but definitely 1 version
• PHP can only write where we allow it, ie it stays on the www-data user
• firewall inbound to CF IPs is limited to http and https, just as SSH access is also severely limited (http can be completely
disabled by likely, CF solves http-> https redirect)
• SSH access is password protected + Cert.
• firewall to the outside, by default everything that is needed (external APIs and their counterparts) is enabled separately
• hosting-type access via SFTP, SSH, although shell access may be possible
CF = CloudFlare (https://www.cloudflare.com/plans/)
edit: we have had such web servers for years, nothing is secure, but we try to make it that way