Gerhard Niebisch: Wie teste ich PHP-Skripte und CGI/Perl unter Apache/Win98?

Hallo,

habe mir zum Offline-Testen von CGI- und PHP-Skripten den Apache 1.3.9 fuer Windows, PHP 3 und Perl5
unter Win98 installiert.
PHP-Skripte kann ich offline testen, Perl/CGI-Skripte leider noch nicht - ich komme einfach nicht dahinter,
was ich bei der Konfiguration des Apaches falsch gemacht habe - vielleicht kann mir ja jemand von Euch
auf die Sprünge helfen...

PHP installiert unter e:\php3
Apache installiert unter e:\apache
Perl installiert unter e:\perl

Internetseiten abgespeichert unter e:\webmaster
CGI-BIN unter e:\Apache\cgi-bin

Meine httpd.conf:

===== cut =======

ServerType standalone
ServerRoot "E:/Apache"

PidFile logs/httpd.pid
ScoreBoardFile logs/apache_status

Timeout 300

KeepAlive On
MaxKeepAliveRequests 100
KeepAliveTimeout 15
MaxRequestsPerChild 0
ThreadsPerChild 50

Port 80

ServerAdmin g.niebisch@ranet.de
ServerName 127.0.0.1

DocumentRoot "E:/webmaster"

<Directory />
    Options FollowSymLinks
    AllowOverride None
</Directory>

<Directory "E:/webmaster">
    Options Indexes FollowSymLinks ExecCGI
    AllowOverride None
    Order allow,deny
    Allow from all
</Directory>

UserDir "E:/Apache/users/"

DirectoryIndex index.html index.htm index.php3
AccessFileName .htaccess

<Files .htaccess>
    Order allow,deny
    Deny from all
</Files>

UseCanonicalName On

TypesConfig conf/mime.types

DefaultType text/plain

<IfModule mod_mime_magic.c>
    MIMEMagicFile conf/magic
</IfModule>

HostnameLookups Off

ErrorLog logs/error.log

LogLevel warn
LogFormat "%h %l %u %t "%r" %>s %b "%{Referer}i" "%{User-Agent}i"" combined
LogFormat "%h %l %u %t "%r" %>s %b" common
LogFormat "%{Referer}i -> %U" referer
LogFormat "%{User-agent}i" agent
CustomLog logs/access.log common

ServerSignature On
Alias /icons/ "E:/Apache/icons/"

ScriptAlias /cgi-bin/ "E:/Apache/cgi-bin/"
ScriptAlias /php-bin/ "E:/php3/"
#ScriptAlias /cgi-bin/ "E:/php3/"

#Action application/x-httpd-php3 /php/php.exe
Action application/x-httpd-php3 /cgi-bin/php.exe

<Directory "E:/Apache/cgi-bin">
    AllowOverride None
    Options None
</Directory>

IndexOptions FancyIndexing

AddIconByEncoding (CMP,/icons/compressed.gif) x-compress x-gzip
AddIconByType (TXT,/icons/text.gif) text/*
AddIconByType (IMG,/icons/image2.gif) image/*
AddIconByType (SND,/icons/sound2.gif) audio/*
AddIconByType (VID,/icons/movie.gif) video/*
AddIcon /icons/binary.gif .bin .exe
AddIcon /icons/binhex.gif .hqx
AddIcon /icons/tar.gif .tar
AddIcon /icons/world2.gif .wrl .wrl.gz .vrml .vrm .iv
AddIcon /icons/compressed.gif .Z .z .tgz .gz .zip
AddIcon /icons/a.gif .ps .ai .eps
AddIcon /icons/layout.gif .html .shtml .htm .pdf
AddIcon /icons/text.gif .txt
AddIcon /icons/c.gif .c
AddIcon /icons/p.gif .pl .py
AddIcon /icons/f.gif .for
AddIcon /icons/dvi.gif .dvi
AddIcon /icons/uuencoded.gif .uu
AddIcon /icons/script.gif .conf .sh .shar .csh .ksh .tcl
AddIcon /icons/tex.gif .tex
AddIcon /icons/bomb.gif core
AddIcon /icons/back.gif ..
AddIcon /icons/hand.right.gif README
AddIcon /icons/folder.gif ^^DIRECTORY^^
AddIcon /icons/blank.gif ^^BLANKICON^^

DefaultIcon /icons/unknown.gif

ReadmeName README
HeaderName HEADER

IndexIgnore .??* *~ *# HEADER* README* RCS CVS *,v *,t

AddEncoding x-compress Z
AddEncoding x-gzip gz tgz

AddLanguage en .en
AddLanguage fr .fr
AddLanguage de .de

LanguagePriority en fr de

AddType application/x-httpd-php3-source .phps
AddType application/x-httpd-php3 .php3

AddHandler cgi-script .cgi .pl
Action php3-script /php-bin/php.exe
AddHandler php3-script .php3

BrowserMatch "Mozilla/2" nokeepalive
BrowserMatch "MSIE 5.0b2;" nokeepalive downgrade-1.0 force-response-1.0

BrowserMatch "RealPlayer 5.0" force-response-1.0
BrowserMatch "Java/1.2" force-response-1.0
BrowserMatch "JDK/1.1" force-response-1.0

Als Fehlermeldung erhalte ich einen Internal Server Error.

Im Error-Log finde ich folgendes:

[Tue Oct 12 00:15:41 1999] [error] [client 127.0.0.1]
malformed header from script. Bad header=Hallo Welt: e:/apache/cgi-bin/hallo.pl

===== cut =======

Hallo.pl:
===== cut =======
#!e:/perl/bin/perl.exe
print "Hallo Welt\n";
===== cut =======

Weiß jemand von Euch Rat?

Danke!

Gerhard Niebisch
--------------------------------------
eMail: g.niebisch@ranet.de

  1. Hi,

    Meine httpd.conf:

    bitte beschränke Dich auf's wesentliche - dies war vollkommen unnötig.

    Hallo.pl:
    ===== cut =======
    #!e:/perl/bin/perl.exe
    print "Hallo Welt\n";
    ===== cut =======

    Weiß jemand von Euch Rat?

    Dein Script ist fehlerhaft, und im Error-Log stand schon, woran es lag: Falscher HTTP-Header! Du mußt dem Server _vor_ der Ausgabe des Textes einen Header liefern, also in Deinem Fall wohl

    print "Content-type: text/plain\n\n";

    Jede einzelne Zeile des Headers wird auf \n beendet, nach der letzten Zeile folgt ein zusätzliches \n (Leerzeile). Alles vor dieser Leerzeile ist Header, alles nach dieser Leerzeile ist Content.

    Cheatah