Recently in building Gitweb, Apache is needed to support Perl (CGI enabled)
Find many methods on the Internet, many failed, and finally summed up a successful method of configuration:
First, has been installed on the Apache server
Second, edit/etc/apache2/apache2.conf
First configure Apache support for CGI, plus the following configuration:
LoadModule cgi_module/usr/lib/apache2/modules/mod_cgi.so
Then configure a directory to execute the CGI program, here I take the/var/www directory as an example:
<Directory/var/www/>
Options Indexes followsymlinks execcgi #加上ExecCGI to support CGI programs
allowoverride None
Require All granted
AddHandler cgi-script. exe. pl. CGI #添加cgi程序将要处理的后缀名
</Directory>
End
We create a file in the/var/www directory, test.cgi:
#!/usr/bin/perl-w use
warnings;
Use CGI QW (: standard);
#! Must use ' I ' to define a variable
print header;
My $now _string = LocalTime ();
Print "<b>hello, CGI using Perl!</b><br/>it ' s $now _string now!<br/>";
Restart Apache, Access: localhost/test.cgi can see the content of the page output, to this, Apache support CGI configuration success