SLES 15
Sponsored Link

Apache2 : Use Perl Scripts2019/01/25

 
Enable CGI and use Perl script.
[1] Install Perl.
www:~ #
zypper -n install perl
[2] By default, CGI is allowed under the [/srv/www/cgi-bin] directory.
It's possible to use Perl Scripts to put under the directory. All files under it is processed as CGI, though.
# the settings below is the one for CGI

www:~ #
grep -n "^ *ScriptAlias" /etc/apache2/default-server.conf

72:ScriptAlias /cgi-bin/ "/srv/www/cgi-bin/"
[3] If you'd like to allow CGI in other directories, configure like follows.
For example, allow in [/srv/www/htdocs/cgi-enabled].
www:~ #
vi /etc/apache2/conf.d/cgi-enabled.conf
# create new

# processes .cgi and .pl as CGI scripts

<Directory "/srv/www/htdocs/cgi-enabled">
    Options +ExecCGI
    AddHandler cgi-script .cgi .pl
</Directory>

www:~ #
systemctl restart apache2

[4] Create a CGI test page and access to it from client PC with web browser. It's OK if following page is shown.
www:~ #
vi /srv/www/htdocs/cgi-enabled/index.cgi
#!/usr/bin/perl

print "Content-type: text/html\n\n";
print "<html>\n<body>\n";
print "<div style=\"width: 100%; font-size: 40px; font-weight: bold; text-align: center;\">\n";
print "CGI Test Page";
print "\n</div>\n";
print "</body>\n</html>\n";

www:~ #
chmod 705 /srv/www/htdocs/cgi-enabled/index.cgi

Matched Content