![为什么index.cgi没有被执行,而是显示为内容?](https://linux22.com/image/611087/%E4%B8%BA%E4%BB%80%E4%B9%88index.cgi%E6%B2%A1%E6%9C%89%E8%A2%AB%E6%89%A7%E8%A1%8C%EF%BC%8C%E8%80%8C%E6%98%AF%E6%98%BE%E7%A4%BA%E4%B8%BA%E5%86%85%E5%AE%B9%EF%BC%9F.png)
我正在尝试创建一个带有 index.cgi 的网站(如果可用),将其作为内容提供。在 /etc/apache2/sites-enabled/000-default 中,我有:
DirectoryIndex index.cgi index.html
DocumentRoot /home/jonathan/mirror
DocumentRoot 被赋予 +ExecCGI:
Options +ExecCGI Indexes FollowSymLinks MultiViews
当我访问 localhost 时,它会显示 index.cgi 的源代码:
#!/usr/bin/perl
if ($ENV{"HTTP_HOST"} =~ /^www\./)
{
print "Status: 301 Moved Permanently\n";
print "Location: http://" . substr($ENV{"HTTP_HOST"}, 4) . "\n\n";
}
if ($ENV{"HTTP_HOST"} =~ /^fan/ or $ENV{"HTTP_HOST"} =~ /jonathanscommunity/)
{
print "Status: 301 Moved Permanently\n";
print "Location: http://www.facebook.com/pages/CJS-Hayward/9506801167\n\n";
...
我需要做什么才能执行 /index.cgi 并给出其结果?