Назад | Перейти на главную страницу

Скрипт Python CGI вообще не отображается на веб-сайте. Apache 2 Debian 10

я и мой друг запустили сервер на Debian 10 и на нем работает Apache2. Я написал очень простой веб-сайт и скрипт на Python, чтобы протестировать скрипты cgi. Итак, как правило, после того, как пользователь заполняет форму и нажимает «Отправить», он должен отображать «Hello world», но я получаю сообщение об ошибке 404, в котором говорится, что «Запрошенный URL не был найден на этом сервере». Форма находится в /var/www/html/form/index.html, а сценарий cgi - в /var/www/html/cgi-bin/hello.py

Скрипт Python:

#!/usr/bin/python

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>'

HTML-код:

<!DOCTYPE html>
<html lang=en dir="ltr">
  <head>
    <meta charset="utf-8">
  </head>
  <body>
  <dir class="main">
    <form action="../cgi-bin/hello.py" method="get">
          <fieldset>
              <label for="name">Name</label>
              <input type="text" name="name">
              <label for="mail">E-Mail</label>
              <input type="email" name="email">
              <label type="phone" for="phone">Phone number</label>
              <input type="text" name="phone">
          <input id="submit" class="inputs" type="submit" name="send" value="Wyślij" />
        </fieldset>
        </form>
</dir>
  </body>
</html>

Конфигурация каталога Apache2:

# Sets the default security model of the Apache2 HTTPD server. It does
# not allow access to the root filesystem outside of /usr/share and /var/www.
# The former is used by web applications packaged in Debian,
# the latter may be used for local directories served by the web server. If
# your system is serving content from a sub-directory in /srv you must allow
# access here, or in any related virtual host.
<Directory />
    Options FollowSymLinks
    AllowOverride None
    Require all denied
</Directory>

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

<Directory "/var/www/html/cgi-bin">
    AllowOvveride None
    Options ExecCGI
    Order allow,deny
    Allow from all
</Directory>

<Directory "/var/www/html/cgi-bin">
Options All
</Directory>

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

#<Directory /srv/>
#   Options Indexes FollowSymLinks
#   AllowOverride None
#   Require all granted
#</Directory>