Debian 8 Jessie
Sponsored Link

Use Perl Scripts2015/05/11

 
Enable CGI and Use Perl Scripts.
[1] Install Perl.
root@www:~#
aptitude -y install perl
[2] Configure Apache2. The example settings makes it's possible to use CGI on any directory.
root@www:~#
vi /etc/apache2/mods-enabled/dir.conf
# line 2: add file name that it can access only with directory's name

DirectoryIndex index.html
index.cgi
root@www:~#
vi /etc/apache2/mods-enabled/mime.conf
# line 219: uncomment and add extensions for CGI

AddHandler cgi-script .cgi
.pl
root@www:~#
vi /etc/apache2/sites-enabled/000-default.conf
ServerAdmin webmaster@srv.world
DocumentRoot /var/www/html
# line 13: add

<Directory "/var/www/html">
    AllowOverride All
    Options +ExecCGI
    Require all granted
</Directory>
root@www:~#
a2enmod cgid

Enabling module cgid.
To activate the new configuration, you need to run:
service apache2 restart
root@www:~#
systemctl restart apache2

[3] Create a CGI test page and access to it with web browser. It's OK if following page is shown.
root@www:~#
vi /var/www/html/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";

root@www:~#
chmod 705 /var/www/html/index.cgi

Matched Content