phpbar.de logo

Mailinglisten-Archive

[php] PHP3 auf Netscape Enterprise 3.0

[php] PHP3 auf Netscape Enterprise 3.0

Kristian =?iso-8859-1?Q?K=F6hntopp?= kk_(at)_netuse.de
Thu, 10 Jun 1999 18:31:06 +0200


This is a multi-part message in MIME format.
--------------7CED6691D0955C6F8DDB2055
Content-Type: text/plain; charset=iso-8859-1
Content-Transfer-Encoding: 8bit



Ulrich Babiak wrote:
> > Hat jemand hier PHP3 auf einem NS Enterprise 3.0 Server am
> > laufen? Vielleicht mit dem Redirect-Plugin von Kwazy zusammen?
> 
> Wohl nicht, denn vor kurzem hatte ich hier auch danach gefragt.

Bei mir geht es jetzt.

Ich habe dazu die Anleitung von kwazy ein wenig überarbeiten 
müssen und im Laufe des Abenteuers auch sein Plugin ein wenig
frisiert. Ich habe noch niemals einen Webserver mit einem 
C-Compiler konfiguriert, aber bitte...

Installation im einzelnen (Solaris 2.6):

Sei der Name der Zielmaschine ghost. Sei die Suitespot-
Installation in /opt/local/suitespot-3.0/ mit dem
Webserver in /opt/local/suitespot-3.0/https-ghost.
Sie die DocumentRoot /opt/local/www/pages, das 
CGI-Verzeichnis in /opt/local/www/cgi-bin.

0. Der Server laufe so, daß er statische Seiten aus
der DocRoot und CGI-Programme aus dem /cgi-bin/
starten kann.

1. Man compliziere das nachstehende Programm.

2. Man kopiere die resultierende redirect_cgi.so-Datei
nach /opt/local/suitespot-3.0/plugins/redirect/. Dieses
Verzeichnis ist zuvor anzulegen.

3. Man erzeuge einen passenden MIME-Type in 
/opt/local/suitespot-3.0/https-ghost/config/mime.types:

type=magnus-internal/php         exts=php3,phtml

Einzutragen ganz am Ende im selben Block wie die 
anderen magnus-internal Typen.

4. Man trage das Plugin in der obj.conf ein (nicht wie
in der Anleitung von kwazy beschrieben in der magnus.conf).
Ganz am Anfang, nach den anderen Init-Statements:

Init fn="load-modules" \
	funcs="redirect-cgi" \
	shlib="/opt/local/suitespot-3.0/plugins/redirect/redirect_cgi.so" \
	NativeThread="no"

5. Man trage einen ObjectType in der obj.conf für das
Default-Objekt ein, nach dem type-by-extension, 
vor dem force-type ObjectType:

ObjectType fn="type-by-extension"
ObjectType fn="redirect-cgi" \
	cgi_path="/opt/local/www/cgi-bin/php" \
	type="magnus-internal/php" \
	debug="no"
ObjectType fn="force-type" type="text/plain"

6. Wichtig! Man erzeuge eine Service-Method
für den MIME-Type magnus-internal/cgi für das
Default-Object. Wenn man das nicht macht, gibt
es keinen CGI-Handler und damit kann der Request
nicht geserviced werden. Also nach dem letzten 
ObjectType, vor dem ersten Service kommt:

Service method="(GET|HEAD)" \
	type="magnus-internal/cgi" \
	fn="send-cgi"


Die Reihenfolge aller dieser Einträge ist
tödlich kritisch.


Anbei das kwazy-Modul, das ich leicht gehackt
habe, damit man es debuggen kann.

Kristian

-- 
Kristian Köhntopp, NetUSE Kommunikationstechnologie GmbH
Siemenswall, D-24107 Kiel, Germany, +49 431 386 436 00
Using PHP3? See our web development library at
http://phplib.shonline.de/ (GPL)
--------------7CED6691D0955C6F8DDB2055
Content-Type: application/x-shar;
 name="redirect.shar"
Content-Transfer-Encoding: 7bit
Content-Disposition: inline;
 filename="redirect.shar"

#!/bin/sh
# This is a shell archive (produced by GNU sharutils 4.2).
# To extract the files from this archive, save it to some FILE, remove
# everything before the `!/bin/sh' line above, then type `sh FILE'.
#
# Made on 1999-06-10 18:27 MET DST by <kk_(at)_poe>.
# Source directory was `/home/kk'.
#
# Existing files will *not* be overwritten unless `-c' is specified.
#
# This shar contains:
# length mode       name
# ------ ---------- ------------------------------------------
#   5160 -rw-r--r-- redirect/redirect_cgi.c
#   3368 -rw-r--r-- redirect/README
#   1588 -rw-r--r-- redirect/Makefile
#
save_IFS="${IFS}"
IFS="${IFS}:"
gettext_dir=FAILED
locale_dir=FAILED
first_param="$1"
for dir in $PATH
do
  if test "$gettext_dir" = FAILED && test -f $dir/gettext \
     && ($dir/gettext --version >/dev/null 2>&1)
  then
    set `$dir/gettext --version 2>&1`
    if test "$3" = GNU
    then
      gettext_dir=$dir
    fi
  fi
  if test "$locale_dir" = FAILED && test -f $dir/shar \
     && ($dir/shar --print-text-domain-dir >/dev/null 2>&1)
  then
    locale_dir=`$dir/shar --print-text-domain-dir`
  fi
done
IFS="$save_IFS"
if test "$locale_dir" = FAILED || test "$gettext_dir" = FAILED
then
  echo=echo
else
  TEXTDOMAINDIR=$locale_dir
  export TEXTDOMAINDIR
  TEXTDOMAIN=sharutils
  export TEXTDOMAIN
  echo="$gettext_dir/gettext -s"
fi
touch -am 1231235999 $$.touch >/dev/null 2>&1
if test ! -f 1231235999 && test -f $$.touch; then
  shar_touch=touch
else
  shar_touch=:
  echo
  $echo 'WARNING: not restoring timestamps.  Consider getting and'
  $echo "installing GNU \`touch', distributed in GNU File Utilities..."
  echo
fi
rm -f 1231235999 $$.touch
#
if mkdir _sh05038; then
  $echo 'x -' 'creating lock directory'
else
  $echo 'failed to create lock directory'
  exit 1
fi
# ============= redirect/redirect_cgi.c ==============
if test ! -d 'redirect'; then
  $echo 'x -' 'creating directory' 'redirect'
  mkdir 'redirect'
fi
if test -f 'redirect/redirect_cgi.c' && test "$first_param" != -c; then
  $echo 'x -' SKIPPING 'redirect/redirect_cgi.c' '(file already exists)'
else
  $echo 'x -' extracting 'redirect/redirect_cgi.c' '(text)'
  sed 's/^X//' << 'SHAR_EOF' > 'redirect/redirect_cgi.c' &&
/***[redirect_cgi.c]**********************************************[TAB=4]****\
*                                                                            *
* NSAPI CGI Redirection Module                                               *
*                                                                            *
* Copyright 1995,1996 Rasmus Lerdorf <rasmus_(at)_vex.net>                        *
*                                                                            *
*  This program is free software; you can redistribute it and/or modify      *
*  it under the terms of the GNU General Public License as published by      *
*  the Free Software Foundation; either version 2 of the License, or         *
*  (at your option) any later version.                                       *
*                                                                            *
*  This program is distributed in the hope that it will be useful,           *
*  but WITHOUT ANY WARRANTY; without even the implied warranty of            *
*  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the             *
*  GNU General Public License for more details.                              *
*                                                                            *
*  You should have received a copy of the GNU General Public License         *
*  along with this program; if not, write to the Free Software               *
*  Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.                 *
*                                                                            *
*  8/28/98 - Modified by Landon Bradshaw                                     *
*            Added the HTTP_REDIRECT_STATUS to the environment so that you   *
*            you can compile PHP with --force-redirect-status                *
*                                                                            *
*  9/4/98  - Modified by Landon Bradshaw                                     *
*            Added the check to see if PHP is being called by the server to  *
*            process an index.phtml.  Finds out if rqpath->value ends with   *
*            '/' and then appends "index.pthml" to the calling string.       *
*  9/23/98 - Modified by Landon Bradshaw                                     *
*            Took out the query test that added the QUERY_STRING to the end  *
*            the file argument.  Fixes GET to the script.                    *
\****************************************************************************/
#include "base/pblock.h"
#include "frame/http.h"
#include "frame/log.h"
#include <string.h>
X
int redirect_cgi(pblock *pb, Session *sn, Request *rq) {
X
X	int l=0, lr=0, lq=0, lc=0;
X	char *rpath, *pi;
X
X	pb_param *path   = pblock_find("path", rq->vars);
X	pb_param *rqpath = pblock_find("uri", rq->reqpb);
X	pb_param *query  = pblock_find("query", rq->reqpb);
X	pb_param *ctype  = pblock_find("content-type", rq->srvhdrs);
X
X	char *cgi_path   = pblock_findval("cgi_path", pb);
X	char *type       = pblock_findval("type", pb);
X	char *debug      = pblock_findval("debug", pb);
X
X	/* Kris arbeitet hier dran - bitte absprechen! */
X	if (debug && !strcmp(debug, "yes"))
X		log_error(LOG_MISCONFIG, "redirect-cgi-debug", sn, rq, 
X			"module called"); 
X
X    if(!cgi_path || !type || !debug) {
X        log_error(LOG_MISCONFIG, "redirect-cgi", sn, rq, 
X			"missing parameters (need cgi_path, type and debug)");
X		return REQ_ABORTED;
X	}
X	l = strlen(path->value);
X	lr = strlen(rqpath->value);
X	if(query)
X		lq = strlen(query->value);
X	lc = strlen(cgi_path);
X
X	if (!strcmp(debug, "yes") && path && path->value)
X		log_error(LOG_MISCONFIG, "redirect-cgi-debug path", sn, rq, path->value);
X	if (!strcmp(debug, "yes") && rqpath && rqpath->value)
X		log_error(LOG_MISCONFIG, "redirect-cgi-debug rqpath", sn, rq, rqpath->value);
X	if (!strcmp(debug, "yes") && query && query->value)
X		log_error(LOG_MISCONFIG, "redirect-cgi-debug query", sn, rq, query->value);
X	if (!strcmp(debug, "yes") && cgi_path)
X		log_error(LOG_MISCONFIG, "redirect-cgi-debug cgi_path", sn, rq, cgi_path);
X	if (!strcmp(debug, "yes") && ctype && ctype->value)
X		log_error(LOG_MISCONFIG, "redirect-cgi-debug ctype", sn, rq, ctype->value);
X
X
X	if(l && !strcmp(ctype->value,type)) {
X		if (!strcmp(debug, "yes"))
X			log_error(LOG_MISCONFIG, "redirect-cgi-debug ctype match", sn, rq, "is true");
X
X		rpath = (char *)MALLOC(lc + 1);
X		pi = (char *)MALLOC(lr + lq + 12);
X		strcpy(rpath,cgi_path);
X		sprintf(pi,"%s",rqpath->value);
X		if (*(pi+lr-1)=='/') strcat(pi,"index.phtml");
X		FREE(path->value);	
X		path->value = rpath;	
X		FREE(ctype->value);
X		ctype->value = STRDUP("magnus-internal/cgi");
X
X		if (!strcmp(debug, "yes"))
X			log_error(LOG_MISCONFIG, "redirect-cgi-debug new path", sn, rq, path->value);
X		if (!strcmp(debug, "yes"))
X			log_error(LOG_MISCONFIG, "redirect-cgi-debug new pi", sn, rq, pi);
X		if (!strcmp(debug, "yes"))
X			log_error(LOG_MISCONFIG, "redirect-cgi-debug new ctype", sn, rq, ctype->value);
X
X		pblock_nvinsert("path-info", pi, rq->vars);
X		pblock_nvinsert("redirect-status","200", rq->headers);
X		pblock_nvinsert("redirect-status","200", rq->vars);
X	}
X	return REQ_PROCEED;
}
SHAR_EOF
  $shar_touch -am 0610161799 'redirect/redirect_cgi.c' &&
  chmod 0644 'redirect/redirect_cgi.c' ||
  $echo 'restore of' 'redirect/redirect_cgi.c' 'failed'
  if ( md5sum --help 2>&1 | grep 'sage: md5sum \[' ) >/dev/null 2>&1 \
  && ( md5sum --version 2>&1 | grep -v 'textutils 1.12' ) >/dev/null; then
    md5sum -c << SHAR_EOF >/dev/null 2>&1 \
    || $echo 'redirect/redirect_cgi.c:' 'MD5 check failed'
b7d7f5258926868e3a4dcae8aa1e4a4c  redirect/redirect_cgi.c
SHAR_EOF
  else
    shar_count="`LC_ALL= LC_CTYPE= LANG= wc -c < 'redirect/redirect_cgi.c'`"
    test 5160 -eq "$shar_count" ||
    $echo 'redirect/redirect_cgi.c:' 'original size' '5160,' 'current size' "$shar_count!"
  fi
fi
# ============= redirect/README ==============
if test -f 'redirect/README' && test "$first_param" != -c; then
  $echo 'x -' SKIPPING 'redirect/README' '(file already exists)'
else
  $echo 'x -' extracting 'redirect/README' '(text)'
  sed 's/^X//' << 'SHAR_EOF' > 'redirect/README' &&
X         REDIRECT-CGI Module for Netscape Servers
X   Version 1.2 Copyright 1996 Rasmus Lerdorf <rasmus_(at)_vex.net>
X
LICENSE
-------           
X  This program is free software; you can redistribute it and/or modify
X  it under the terms of the GNU General Public License as published by
X  the Free Software Foundation; either version 2 of the License, or
X  (at your option) any later version.
X
X  This program is distributed in the hope that it will be useful,
X  but WITHOUT ANY WARRANTY; without even the implied warranty of
X  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
X  GNU General Public License for more details.
X
X  You should have received a copy of the GNU General Public License
X  along with this program; if not, write to the Free Software
X  Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
X
X  See the file, COPYING, for the complete terms of the GPL.
X
X
INTRODUCTION
------------
X  This is a standard NSAPI module which allows you to redirect any
X  request to a given cgi program based on the extension of the
X  requested file.  This is particularly useful for the PHP/FI package
X  (http://www.vex.net/php).  The examples in the installation
X  instructions refer to php.cgi for this reason.  This module will
X  however work equally well with other cgi programs.
X
X  Please note that I don't use Netscape servers myself.  I only know
X  enough about them to be dangerous and enough to write this module.
X  Chances are that I won't be able to answer specific installation
X  questions for you.  You are pretty much on your own here.
X
X
INSTALLATION
------------
X  Your first step is to compile the module.  The included Makefile is
X  configured for Solaris.  You will need to modify it to reflect your
X  local compiler conventions for creating shared libraries.  Read the
X  Makefile.  There are some hints for other operating systems.  
X
X  Once you have a redirect_cgi.so shared library, you need to edit three
X  different server configuration files.  These are in your ns-home
X  config directory.
X
X  In mime.types, add the following line to the end of the file:
X
type=magnus-internal/php exts=phtml
X
X  This creates a new mime type to be used internally by the server.
X  You may substitute "php" with whatever you like.  Substitute phtml
X  with whatever extension you wish to use to base the redirection on.
X
X  In magnus.conf add the following line to the end of the file:
X
Init fn=load-modules shlib=/www/nsapi/redirect_cgi.so funcs=redirect-cgi
X
X  Replace the /www/nsapi with the path to your redirect_cgi.so file.
X  It can be anywhere on your system.
X
X  Finally, in obj.conf, you need to insert the following line:
X
ObjectType fn="redirect-cgi" cgi_path="/www/cgi-bin/php.cgi" type="magnus-internal/php"
X
X  Here, replace /www/cgi-bin/php.cgi with the path to your cgi program.
X  Also, replace the type with the type you configured in the mime.types file.
X  The line should be inserted after the "type-by-extension" line, but before
X  the "force-type" line.
X
X  If you want to have multiple cgi redirections, simply add more mime types
X  to mime.types and add multiple ObjectType lines to obj.conf.
X
X  Note that if you are running multiple servers, you will need to configure
X  each one individually according to the above instructions.
X
X  The most recent version of this module can be found in the file archive
X  at http://www.vex.net/php.
X
SHAR_EOF
  $shar_touch -am 0828172098 'redirect/README' &&
  chmod 0644 'redirect/README' ||
  $echo 'restore of' 'redirect/README' 'failed'
  if ( md5sum --help 2>&1 | grep 'sage: md5sum \[' ) >/dev/null 2>&1 \
  && ( md5sum --version 2>&1 | grep -v 'textutils 1.12' ) >/dev/null; then
    md5sum -c << SHAR_EOF >/dev/null 2>&1 \
    || $echo 'redirect/README:' 'MD5 check failed'
f1fb5dc4b9e0263f6989e0b1d980aff1  redirect/README
SHAR_EOF
  else
    shar_count="`LC_ALL= LC_CTYPE= LANG= wc -c < 'redirect/README'`"
    test 3368 -eq "$shar_count" ||
    $echo 'redirect/README:' 'original size' '3368,' 'current size' "$shar_count!"
  fi
fi
# ============= redirect/Makefile ==============
if test -f 'redirect/Makefile' && test "$first_param" != -c; then
  $echo 'x -' SKIPPING 'redirect/Makefile' '(file already exists)'
else
  $echo 'x -' extracting 'redirect/Makefile' '(text)'
  sed 's/^X//' << 'SHAR_EOF' > 'redirect/Makefile' &&
# ** CONFIGURE THIS **
# Edit the following to reflect the location of your nsapi include directory.
# 
INCLUDEDIR=/opt/local/suitespot-3.0/include
X
#
# Now, pick your operating system
#
X
X
# For Solaris (using Sun's compiler)
CC_CMD=cc -DSOLARIS
SHARED=-G
X
#
# I haven't tested on any platform except Solaris.  If you find
# that some of these work, or if you make it work on any platform
# except Solaris, please e-mail me at: rasmus_(at)_vex.net 
# so I can update this file.
#
# For Irix
#CC_CMD=cc -DIRIX
#SHARED=-shared
X
# For SunOS (using gcc)
#CC_CMD=gcc -DSUNOS4 -fpic
#LD_SHAREDCMD=ld -assert pure-text
X
# For OSF/1
#CC_CMD=cc -DOSF
#SHARED=-all -shared -expect_unresolved "*"
X
# For HP-UX
#CC_CMD=cc -DHPUX
#SHARED=-b
X
# For AIX (good luck)
#CC_CMD=cc -DAIX
#SHARED=-bM:SRE -bE:module.exp -bI:module.imp -e _nostart
##module.exp is a file you create which lists each function in your module
##module.imp is a function you create which lists each function which
##           should be exported from the server into the module.
X
INCLUDE_FLAGS=-I$(INCLUDEDIR)
COMMON_DEFS=-DMCC_HTTPD -DXP_UNIX
X
X
#
# For Solaris, use single-step compile and link with the following
all: redirect_cgi.so
X
redirect_cgi.so: redirect_cgi.c
X	$(CC_CMD) $(COMMON_DEFS) $(INCLUDE_FLAGS) $(SHARED) -o redirect_cgi.so redirect_cgi.c
X
#
# For SUNOS, use two-step compile and link.  uncomment the following:
#
#OBJS=redirect_cgi.o
#
#all: redirect_cgi.so
#
#redirect_cgi.so: $(OBJS)
#	$(LD_SHAREDCMD) $(OBJS) -o redirect_cgi.so
#
#.c.o:
#	$(CC_CMD) $(COMMON_DEFS) $(INCLUDE_FLAGS) -c $<
X
clean:
X	rm redirect_cgi.so
SHAR_EOF
  $shar_touch -am 0608103699 'redirect/Makefile' &&
  chmod 0644 'redirect/Makefile' ||
  $echo 'restore of' 'redirect/Makefile' 'failed'
  if ( md5sum --help 2>&1 | grep 'sage: md5sum \[' ) >/dev/null 2>&1 \
  && ( md5sum --version 2>&1 | grep -v 'textutils 1.12' ) >/dev/null; then
    md5sum -c << SHAR_EOF >/dev/null 2>&1 \
    || $echo 'redirect/Makefile:' 'MD5 check failed'
3b25a88b67bfe5dc64a583de80bcd34e  redirect/Makefile
SHAR_EOF
  else
    shar_count="`LC_ALL= LC_CTYPE= LANG= wc -c < 'redirect/Makefile'`"
    test 1588 -eq "$shar_count" ||
    $echo 'redirect/Makefile:' 'original size' '1588,' 'current size' "$shar_count!"
  fi
fi
rm -fr _sh05038
exit 0

--------------7CED6691D0955C6F8DDB2055--



php::bar PHP Wiki   -   Listenarchive