由于 cgi,目录不呈现图像

Directory not rendering images because of cgi

我的服务器不渲染 cgi 目录下的任何图像,我知道这是因为 apache 被告知 运行 该目录下的每个文件都作为 cgi 程序。

我想调整设置以告诉 apache 运行 所有 .cgi 和 .pl 作为 cgi 程序,但 运行 其余文件应该是。

例如,如果我从浏览器转到 example.com/x.gif,我可以看到图像,但如果我转到 example.com/cgi-bin/x.gif,我就不能。 (当然是两个目录中的图像,并且是 775)

问题是我不知道如何告诉 apache,这是 httpd.include

<Directory /var/www/vhosts/example.com/httpdocs>   
<IfModule mod_perl.c>
<Files ~ (\.pl$)>
    SetHandler perl-script
    PerlHandler ModPerl::Registry
    Options ExecCGI
    allow from all
    PerlSendHeader On
</Files> </IfModule> <IfModule mod_python.c>
<Files ~ (\.py$)>
    SetHandler python-program
    PythonHandler mod_python.cgihandler
</Files> </IfModule> <IfModule mod_fcgid.c>
<Files ~ (\.fcgi)>
    SetHandler fcgid-script
    Options +FollowSymLinks +ExecCGI
</Files> </IfModule> <IfModule mod_fcgid.c>
<Files ~ (\.php)>
    SetHandler fcgid-script
    FCGIWrapper /var/www/cgi-bin/cgi_wrapper/cgi_wrapper .php
    Options +ExecCGI
    allow from all
</Files> </IfModule>

    SSLRequireSSL

    Options -Includes +ExecCGI

</Directory>

我找到了解决办法。

正如我所说,apache 被告知 运行 该目录下的每个文件都作为 cgi 程序。因此需要新的规则来告诉 apache 对那些不同于 .php.pl.cgi:

的文件类型使用默认处理程序
<Directory /var/www/vhosts/example.com/httpdocs/cgi-bin>   
<FilesMatch "^(?!.*\.(cgi|php|pl)$).*$">
    SetHandler default-handler
</FilesMatch>
</Directory>

如果您出于任何原因无法访问 httpd.conf,您仍然可以通过 .htaccess 将这三行添加到 [=18= 的 .htaccess 文件中来解决问题]文件夹:

<FilesMatch "^(?!.*\.(cgi|php|pl)$).*$">
    SetHandler default-handler
</FilesMatch>