Centos не удается выполнить сценарий hello.cgi

Я пытаюсь выполнить простую cgi-файл hello world скрипт в каталоге html, но он не работает.

Журнал ошибок:

[Tue May 17 14:56:15.744954 2016] [cgi:error] [pid 29997] [client 192.168.1.1:16151] End of script output before headers: hello.cgi
[Tue May 17 15:00:12.474229 2016] [cgi:error] [pid 29998] [client 192.168.1.1:16597] AH01215: (2)No such file or directory: exec of '/var/www/html/hello.cgi' failed
[Tue May 17 15:00:12.475135 2016] [cgi:error] [pid 29998] [client 192.168.1.1:16597] End of script output before headers: hello.cgi
[Tue May 17 15:00:13.176640 2016] [cgi:error] [pid 29999] [client 192.168.1.1:16600] AH01215: (2)No such file or directory: exec of '/var/www/html/hello.cgi' failed
[Tue May 17 15:00:13.177591 2016] [cgi:error] [pid 29999] [client 192.168.1.1:16600] End of script output before headers: hello.cgi
[Tue May 17 15:00:13.640420 2016] [cgi:error] [pid 30000] [client 192.168.1.1:16603] AH01215: (2)No such file or directory: exec of '/var/www/html/hello.cgi' failed
[Tue May 17 15:00:13.641393 2016] [cgi:error] [pid 30000] [client 192.168.1.1:16603] End of script output before headers: hello.cgi

httpd config:

# Further relax access to the default document root:
<Directory "/var/www/html">
    #
    # Possible values for the Options directive are "None", "All",
    # or any combination of:
    #   Indexes Includes FollowSymLinks SymLinksifOwnerMatch ExecCGI MultiViews
    #
    # Note that "MultiViews" must be named *explicitly* --- "Options All"
    # doesn't give it to you.
    #
    # The Options directive is both complicated and important.  Please see
    # http://httpd.apache.org/docs/2.4/mod/core.html#options
    # for more information.
    #
    Options -Indexes +FollowSymLinks +ExecCGI
    AddHandler cgi-script .cgi .pl

    #
    # AllowOverride controls what directives may be placed in .htaccess files.
    # It can be "All", "None", or any combination of the keywords:
    #   Options FileInfo AuthConfig Limit
    #
    AllowOverride None

    #
    # Controls who can get stuff from this server.
    #
    Require all granted
</Directory>

файл hello.cgi:

#!/usr/bin/perl
print "Content-type: text/html\n\n"; # This is mandatory.
print "<h2>Hello world!</h2>";
0
задан 17 May 2016 в 15:09
1 ответ

Измените первую строку файла сценария на следующую и повторите попытку.

#!/usr/bin/perl -w

Если это устраняет проблему, то файл сценария содержит '\ r \ n' вместо '\ n' как символ новой строки, который обычно используется, когда сценарий не загружается в режиме ASCII с компьютера Windows или MAC.

0
ответ дан 5 December 2019 в 10:24

Теги

Похожие вопросы