I followed the same, and use the perl script from https://perlmaven.com/hello-world-with-plain-cgi, then it works. before loading it from the web, make sure perl xxx works from the SSH console.
#!/usr/bin/perl
use strict;
use warnings;
print "Content-type: text/html\n\n";
print "Hello World!";