CGI benutzen

Apache, Lighttpd, nginx, Cherokee
Giamatti1988
Posts: 22
Joined: 2012-01-29 11:20
Location: Berlin

CGI benutzen

Post by Giamatti1988 » 2012-01-29 11:33

Hallo liebe gemeinde,

ich habe hier ein naja eher winziges Problem, welches mir wie nen unüberwindbares hinderniss vorkommt.

Ich habe auf meinem VServer reineweg Debian 6 mit Apache2 und php5 installiert.

nun wollt ich aber auch noch CGI benutzen, nur leider hapert es dort ein wenig.

Ich habe in der Apache Config meiner Domain (die ich dazu verwende) die Config insoweit angepasst um CGI zu benutzen darüber.

Code: Select all

<VirtualHost *:80>
  ServerName meinedomain.de.vu
  ServerAlias *.meinedomain.de.vu
  ServerAdmin root@meinedomain.de.vu
  DocumentRoot "/home/www/meinedomain.de.vu/htdocs"

  ScriptAlias /cgi-bin/ /home/www/meinedomain.de.vu/cgi-bin/

  php_admin_value open_basedir "/home/www/meinedomain.de.vu/htdocs:/tmp/"
  php_admin_flag safe_mode Off
  ErrorLog "/home/www/meinedomain.de.vu/logs/error.log"
 
  <Directory /home/www/meinedomain.de.vu/htdocs>
    Options Indexes FollowSymLinks MultiViews
    AllowOverride None
    Order allow,deny
    allow from all
  </Directory>

  <Directory "/home/www/meinedomain.de.vu/cgi-bin/">
    AllowOverride None
    Options +ExecCGI -Includes
    Order allow,deny
    Allow from all
  </Directory>
</VirtualHost>


so nun habe ich übers web dann das CGI Script aufgerufen und erhalte ein ERROR 500

anhand der Logfiles erhalte ich diese Information

Code: Select all

[Sun Jan 29 11:13:24 2012] [error] [client 91.66.***.***] (13)Permission denied: exec of '/home/www/meinedomain.de.vu/cgi-bin/first.pl' failed
[Sun Jan 29 11:13:24 2012] [error] [client 91.66.***.***] Premature end of script headers: first.pl


so anhand dieser meldung seh ich ja er kann auf irgend etwas nicht zugreifen oder versteh ich dies falsch?

so wenn ich aber das Script per shell abrufe

perl first.pl dann erhalte ich die ausgabe in HTML

Code: Select all

root@vps43010:/home/www/meinedomain.de.vu/cgi-bin# perl first.pl
Content-type: text/html

<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
<html>
<head>
<title></title>
<meta http-equiv="Content-Type" content="text/html">
<link rel="stylesheet" type="text/css" href="../../css/style.css">
</head>
<body>
<table cellspacing="0" cellpadding="0" border="0">
<tr class="subhead" align="Left"><th>Name</th><th>Value</th></tr>
</table>
</body>
</html>


so nun die Endgültige Frage, wie bekomm ich das nun hin, das ich über den Webbrowser auch eine Ausgabe erhalte, die Vielversprechender ist als die meldung ERROR 500?

Um Aussagen wie Bitte genauer Lesen vorzubeugen, ich habe diese anleitung hier befolgt...
http://httpd.apache.org/docs/2.0/howto/cgi.html

User avatar
Joe User
Project Manager
Project Manager
Posts: 11599
Joined: 2003-02-27 01:00
Location: Hamburg

Re: CGI benutzen

Post by Joe User » 2012-01-29 12:36

Bitte zunächst mal folgende Ausgaben posten:

Code: Select all

ls -alh /home/www/meinedomain.de.vu/ /home/www/meinedomain.de.vu/cgi-bin/

cat /home/www/meinedomain.de.vu/cgi-bin/first.pl

grep -rin 'script' /etc/apache2
PayPal.Me/JoeUserFreeBSD Remote Installation
Wings for LifeWings for Life World Run

„If there’s more than one possible outcome of a job or task, and one
of those outcomes will result in disaster or an undesirable consequence,
then somebody will do it that way.“ -- Edward Aloysius Murphy Jr.

Giamatti1988
Posts: 22
Joined: 2012-01-29 11:20
Location: Berlin

Re: CGI benutzen

Post by Giamatti1988 » 2012-01-29 13:06

Hier die Ausgabe zum Befehl.:
ls -alh /home/www/meinedomain.de.vu/ /home/www/meinedomain.de.vu/cgi-bin/

Code: Select all

root@vps43010:~# ls -alh /home/www/meinedomain.de.vu/ /home/www/meinedomain.de.vu/cgi-bin/
/home/www/shoutcast-sponsor.de.vu/:
total 168M
drwxr-xr-x  6 root root 4.0K Jan 29 11:35 .
drwxr-xr-x 11 root root 4.0K Jan 29 11:35 ..
-rw-r--r--  1 root root 168M Jan 27 12:00 archive.tgz
drwxr-xr-x  3 root root 4.0K Jan 29 12:10 cgi-bin
drwxr-xr-x  2 root root 4.0K Dec 13 13:42 conf
drwxr-xr-x  8 root root 4.0K Jan 29 12:28 htdocs
drwxr-xr-x  2 root root 4.0K Dec 13 03:20 logs

/home/www/meinedomain.de.vu/cgi-bin/:
total 20K
drwxr-xr-x 3 root     root     4.0K Jan 29 12:10 .
drwxr-xr-x 6 root     root     4.0K Jan 29 11:35 ..
-rw-r--r-- 1 www-data www-data  662 Jan 29 11:13 first.pl
drwxr-xr-x 2 root     root     4.0K Jan 29 11:35 test


Der Inhalt der first.pl

Code: Select all

#!/usr/bin/perl

print <<HTML;
Content-type: text/html

<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
<html>
<head>
<title></title>
<meta http-equiv="Content-Type" content="text/html">
<link rel="stylesheet" type="text/css" href="../../css/style.css">
</head>
<body>
<table cellspacing="0" cellpadding="0" border="0">
<tr class="subhead" align="Left"><th>Name</th><th>Value</th></tr>
HTML

my $class;

foreach (sort keys %ENV) {
   next unless /^HTTP_|^REQUEST_/;
   $class = ($class ne 'normal')? 'normal': 'alt';
   print <<HTML;
<tr class="$class"><td valign="top">$_</td><td>$ENV{$_}</td></tr>
HTML
}

print <<HTML;
</table>
</body>
</html>
HTML



grep -rin 'script' /etc/apache2

Code: Select all

/etc/apache2/envvars:13:# Since there is no sane way to get the parsed apache2 config in scripts, some
/etc/apache2/mods-enabled/autoindex.conf:11:IndexOptions FancyIndexing VersionSort HTMLTable NameWidth=* DescriptionWidth=* Charset=UTF-8
/etc/apache2/mods-enabled/autoindex.conf:38:AddIcon /icons/script.gif .conf .sh .shar .csh .ksh .tcl
/etc/apache2/mods-enabled/autoindex.conf:77:# AddDescription allows you to place a short description after a file in
/etc/apache2/mods-enabled/autoindex.conf:80:# Format: AddDescription "description" filename
/etc/apache2/mods-enabled/autoindex.conf:82:#AddDescription "GZIP compressed document" .gz
/etc/apache2/mods-enabled/autoindex.conf:83:#AddDescription "tar archive" .tar
/etc/apache2/mods-enabled/autoindex.conf:84:#AddDescription "GZIP compressed tar archive" .tgz
/etc/apache2/mods-enabled/deflate.conf:7:          AddOutputFilterByType DEFLATE application/x-javascript application/javascript application/ecmascript
/etc/apache2/mods-enabled/mime.conf:50:# avoid the ambiguity with the common suffix for perl scripts.
/etc/apache2/mods-enabled/mime.conf:85:# es is ecmascript in /etc/mime.types
/etc/apache2/mods-enabled/mime.conf:215:# To use CGI scripts outside of ScriptAliased directories:
/etc/apache2/mods-enabled/mime.conf:218:#AddHandler cgi-script .cgi
/etc/apache2/mods-available/cgid.conf:2:ScriptSock ${APACHE_RUN_DIR}/cgisock
/etc/apache2/mods-available/autoindex.conf:11:IndexOptions FancyIndexing VersionSort HTMLTable NameWidth=* DescriptionWidth=* Charset=UTF-8
/etc/apache2/mods-available/autoindex.conf:38:AddIcon /icons/script.gif .conf .sh .shar .csh .ksh .tcl
/etc/apache2/mods-available/autoindex.conf:77:# AddDescription allows you to place a short description after a file in
/etc/apache2/mods-available/autoindex.conf:80:# Format: AddDescription "description" filename
/etc/apache2/mods-available/autoindex.conf:82:#AddDescription "GZIP compressed document" .gz
/etc/apache2/mods-available/autoindex.conf:83:#AddDescription "tar archive" .tar
/etc/apache2/mods-available/autoindex.conf:84:#AddDescription "GZIP compressed tar archive" .tgz
/etc/apache2/mods-available/actions.conf:4:# Action lets you define media types that will execute a script whenever
/etc/apache2/mods-available/actions.conf:7:# Format: Action media/type /cgi-script/location
/etc/apache2/mods-available/actions.conf:8:# Format: Action handler-name /cgi-script/location
/etc/apache2/mods-available/deflate.conf:7:          AddOutputFilterByType DEFLATE application/x-javascript application/javascript application/ecmascript
/etc/apache2/mods-available/mime.conf:50:# avoid the ambiguity with the common suffix for perl scripts.
/etc/apache2/mods-available/mime.conf:85:# es is ecmascript in /etc/mime.types
/etc/apache2/mods-available/mime.conf:215:# To use CGI scripts outside of ScriptAliased directories:
/etc/apache2/mods-available/mime.conf:218:#AddHandler cgi-script .cgi
/etc/apache2/conf.d/localized-error-pages:9:#ErrorDocument 402 http://www.example.com/subscription_info.html
/etc/apache2/magic:205:# c-lang:  file(1) magic for C programs or various scripts
/etc/apache2/magic:226:0       string          #!/bin/sh               application/x-shellscript
/etc/apache2/magic:227:0       string          #!\ /bin/sh             application/x-shellscript
/etc/apache2/magic:228:0       string          #!/bin/csh              application/x-shellscript
/etc/apache2/magic:229:0       string          #!\ /bin/csh            application/x-shellscript
/etc/apache2/magic:231:0       string          #!/bin/ksh              application/x-shellscript
/etc/apache2/magic:232:0       string          #!\ /bin/ksh            application/x-shellscript
/etc/apache2/magic:233:0       string          #!/bin/tcsh             application/x-shellscript
/etc/apache2/magic:234:0       string          #!\ /bin/tcsh           application/x-shellscript
/etc/apache2/magic:235:0       string          #!/usr/local/tcsh       application/x-shellscript
/etc/apache2/magic:236:0       string          #!\ /usr/local/tcsh     application/x-shellscript
/etc/apache2/magic:237:0       string          #!/usr/local/bin/tcsh   application/x-shellscript
/etc/apache2/magic:238:0       string          #!\ /usr/local/bin/tcsh application/x-shellscript
/etc/apache2/magic:240:0       string          #!/bin/bash           application/x-shellscript
/etc/apache2/magic:241:0       string          #!\ /bin/bash           application/x-shellscript
/etc/apache2/magic:242:0       string          #!/usr/local/bin/bash   application/x-shellscript
/etc/apache2/magic:243:0       string          #!\ /usr/local/bin/bash application/x-shellscript
/etc/apache2/magic:247:0       string          #!/bin/zsh           application/x-shellscript
/etc/apache2/magic:248:0       string          #!/usr/bin/zsh           application/x-shellscript
/etc/apache2/magic:249:0       string          #!/usr/local/bin/zsh    application/x-shellscript
/etc/apache2/magic:250:0       string          #!\ /usr/local/bin/zsh  application/x-shellscript
/etc/apache2/magic:251:0       string          #!/usr/local/bin/ash    application/x-shellscript
/etc/apache2/magic:252:0       string          #!\ /usr/local/bin/ash  application/x-shellscript
/etc/apache2/magic:537:# PostScript
/etc/apache2/magic:538:0   string      %!      application/postscript
/etc/apache2/magic:539:0   string      \004%!      application/postscript
/etc/apache2/magic:564:#0   string      This\ is\ TeX,   TeX transcript text   
/etc/apache2/magic:565:#0   string      This\ is\ METAFONT,   METAFONT transcript text
/etc/apache2/sites-enabled/meinedomain.de.vu.conf:11:  ScriptAlias /cgi-bin/ /home/www/meinedomain.de.vu/cgi-bin/
/etc/apache2/sites-available/meinedomain.de.vu.conf:11:  ScriptAlias /cgi-bin/ /home/www/meinedomain.de.vu/cgi-bin/

Giamatti1988
Posts: 22
Joined: 2012-01-29 11:20
Location: Berlin

Re: CGI benutzen

Post by Giamatti1988 » 2012-01-29 13:13

oke naja was soll man sagen
das einfachste was man machen kann ist die Doofheit siegen lassen xD

nein scherz

habs hinbekommen nun. Scheint wohl der fehler gewesen zu sein das ich die rechte falsch gesetzt habe...

und in der mime.conf vergessen hatte die CGI Scripte zu aktivieren also das (#) davor weg nehmen und apache restarten...

weia
Last edited by Giamatti1988 on 2012-01-29 13:15, edited 1 time in total.

User avatar
Joe User
Project Manager
Project Manager
Posts: 11599
Joined: 2003-02-27 01:00
Location: Hamburg

Re: CGI benutzen

Post by Joe User » 2012-01-29 13:45

Manchmal sind es halt die einfachsten Dinge, die man übersieht ;)
PayPal.Me/JoeUserFreeBSD Remote Installation
Wings for LifeWings for Life World Run

„If there’s more than one possible outcome of a job or task, and one
of those outcomes will result in disaster or an undesirable consequence,
then somebody will do it that way.“ -- Edward Aloysius Murphy Jr.

Giamatti1988
Posts: 22
Joined: 2012-01-29 11:20
Location: Berlin

Re: CGI benutzen

Post by Giamatti1988 » 2012-01-29 14:09

genau aber dennoch danke für den Lösungsansatz *zwinker*