Apache2.4.10 на Ubuntu, возвращая Внутреннюю ошибку сервера при запущении скриптов CGI

Я выполняю Apache/2.4.10 (Ubuntu), и я пытался запустить скрипты CGI со следующими конфигурациями.

/etc/apache2/apache2.conf

Со следующим

Mutex file:${APACHE_LOCK_DIR} default
PidFile ${APACHE_PID_FILE}
Timeout 300
KeepAlive On
MaxKeepAliveRequests 100
KeepAliveTimeout 5
User ${APACHE_RUN_USER}
Group ${APACHE_RUN_GROUP}
HostnameLookups Off
ErrorLog ${APACHE_LOG_DIR}/error.log
LogLevel warn
IncludeOptional mods-enabled/*.load
IncludeOptional mods-enabled/*.conf
Include ports.conf
<Directory />
    Options FollowSymLinks
    AllowOverride None
    Require all denied
</Directory>

<Directory /usr/share>
    AllowOverride None
    Require all granted
</Directory>

<Directory /var/www/>
    Options Indexes FollowSymLinks
    AllowOverride None
    Require all granted
</Directory>

AccessFileName .htaccess

<FilesMatch "^\.ht">
    Require all denied
</FilesMatch>

LogFormat "%v:%p %h %l %u %t \"%r\" %>s %O \"%{Referer}i\" \"%{User-Agent}i\"" vhost_combined
LogFormat "%h %l %u %t \"%r\" %>s %O \"%{Referer}i\" \"%{User-Agent}i\"" combined
LogFormat "%h %l %u %t \"%r\" %>s %O" common
LogFormat "%{Referer}i -> %U" referer
LogFormat "%{User-agent}i" agent

IncludeOptional conf-enabled/*.conf
IncludeOptional sites-enabled/*.conf

###################################################################
#########     Adding capaility to run CGI-scripts #################
ServerName localhost
ScriptAlias /cgi-bin/ /var/www/cgi-bin/
Options +ExecCGI
AddHandler cgi-script .cgi .pl .py

И /etc/apache2/conf-available/serve-cgi-bin.conf

<IfModule mod_alias.c>
    <IfModule mod_cgi.c>
        Define ENABLE_USR_LIB_CGI_BIN
    </IfModule>

    <IfModule mod_cgid.c>
        Define ENABLE_USR_LIB_CGI_BIN
    </IfModule>

    <IfDefine ENABLE_USR_LIB_CGI_BIN>
        #ScriptAlias /cgi-bin/ /usr/lib/cgi-bin/
        #<Directory "/usr/lib/cgi-bin">
        #   AllowOverride None
        #   Options +ExecCGI -MultiViews +SymLinksIfOwnerMatch
        #   Require all granted
        #</Directory>

        ## cgi-bin config
        ScriptAlias /cgi-bin/ /var/www/cgi-bin/
            <Directory "/var/www/cgi-bin/">
                AllowOverride None
                Options +ExecCGI 
            </Directory>

    </IfDefine>
</IfModule>

# vim: syntax=apache ts=4 sw=4 sts=4 sr noet

У меня есть мой cgi-script в каталоге /var/www/cgi-bin

с содержанием в hello.py и сделанный этим исполняемый файл.

#!/usr/bin/env python

import cgitb
    cgitb.enable()    print("Content-Type: text/html;charset=utf-8")

print "Content-type:text/html\r\n\r\n"
print '<html>'
print '<head>'
print '<title>Hello Word - First CGI Program</title>'
print '</head>'
print '<body>'
print '<h2>Hello Word! This is my first CGI program</h2>'
print '</body>'
print '</html>'

Я также сделал sudo a2enmod cgi как предложено здесь Apache2.4.7 на Ubuntu 14.04 не выполнит Python cgi файл. Сайт отображает код Python вместо этого

Когда я пытаюсь запустить скрипт путем движения в http://localhost/cgi-bin/hello.py, я получаю a 500 Internal Server error.

Любая справка значительно ценилась бы!Спасибо

0
задан 13 April 2017 в 15:24

1 ответ

Видел журналы ошибок в /var/log/apache2/error.log и видел, что существует ошибка добавления отступа из-за cgitb.enable().

Исправленный добавление отступа и теперь то, что это хорошо работало.

0
ответ дан 1 October 2019 в 00:56

Другие вопросы по тегам:

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