Solution for thttpd 2.17 problems with PHP4
| From: | Albert Siersema | Date: | Mon, 29 May 2000 18:37:05 +0000 |
| Subject: | Solution for thttpd 2.17 problems with PHP4 | ||
| Groups: | php.dev | ||
| Request: | Send a blank email to php-dev+get-19705@lists.php.net to get a copy of this message | ||
I hope the following solution to my serious problems getting PHP4 working with thttpd 2.17
will help other people as well. I admit it's not a super simple solution, i'll leave that
to the thttpd maintainer or the PHP4 developpers :-)
In the following I presume you have un-tar-gz-ed the thttpd sources in
/root/thttpd-2.17-php4
and the php4 sources in:
/root/php-4.0.0
First thttpd:
- edit configure
at the bottom you'll find a line reading 'rm -fr confdefs* $ac_clean_files'
Remove the 'confdefs*' part from that line so that it reads
rm -fr ac_clean_files
(I should get this from the -DEFS in the Makefile somehow but okay this works)
- ./configure
- make
Proceed to PHP4:
- ./configure --with-thttpd=/root/thttpd-2.17-php4
- Replace the thttpd patch (see below for the new patch):
cp thttpd-php4_patch /root/php-4.0.0/sapi/thttpd/thttpd_patch
- Add 'confdefs' to the file /root/php-4.0.0/sapi/thttpd/php_thttpd.h
#include "/root/thttpd-2.17-php4/confdefs.h"
#include <libhttpd.h>
- make
- make install
Back to thttpd:
- make clean ; make
the new thttpd patch (thttpd-php4_patch)
----------------------------------------
diff -ur thttpd-2.17/Makefile.in thttpd-2.17-php4/Makefile.in
--- thttpd-2.17/Makefile.in Sat Jan 8 18:09:08 2000 +++ thttpd-2.17-php4/Makefile.in Tue May 30 02:28:46 2000@@ -46,13 +46,15 @@ # You shouldn't need to edit anything below here. +include php_makefile +
CC = @CC@ CCOPT = @V_CCOPT@ DEFS = @DEFS@ INCLS = -I. CFLAGS = $(CCOPT) $(DEFS) $(INCLS) -LDFLAGS = @LDFLAGS@ -LIBS = @LIBS@ +LDFLAGS = @LDFLAGS@ $(PHP_LDFLAGS) +LIBS = @LIBS@ $(PHP_LIBS) NETLIBS = @V_NETLIBS@ INSTALL = @INSTALL@diff -ur thttpd-2.17/libhttpd.c thttpd-2.17-php4/libhttpd.c
--- thttpd-2.17/libhttpd.c Wed May 10 19:19:23 2000+++ thttpd-2.17-php4/libhttpd.c Tue May 30 02:28:46 2000 @@ -75,6 +75,8 @@ #include "match.h" #include "tdate_parse.h" +#include "php_thttpd.h" + #ifndef STDIN_FILENO #define STDIN_FILENO 0 #endif @@ -228,7 +230,10 @@
free( (void*) hs->url_pattern );
if ( hs->local_pattern != (char*) 0 )
free( (void*) hs->local_pattern );
+ if ( hs->php_pattern != (char*) 0 )
+ free( (void *) hs->php_pattern );
free( (void*) hs );
+ thttpd_php_shutdown();
}
@@ -289,6 +294,7 @@
}
hs->port = port;
+ hs->php_pattern = strdup("*.php");
if ( cgi_pattern == (char*) 0 )
hs->cgi_pattern = (char*) 0;
else
@@ -339,6 +345,7 @@
hs->no_symlink = no_symlink;
hs->vhost = vhost;
hs->no_empty_referers = no_empty_referers;
+ thttpd_php_init();
/* Initialize listen sockets. */
if ( sa4P == (httpd_sockaddr*) 0 )
@@ -3293,6 +3300,11 @@
( hc->sb.st_mode & S_IXOTH ) &&
match( hc->hs->cgi_pattern, hc->expnfilename ) )
return cgi( hc );
+
+ if ( hc->hs->php_pattern != (char*) 0 &&
+ match( hc->hs->php_pattern, hc->expnfilename)) {
+ return thttpd_php_request( hc );
+ }
/* It's not CGI. If it's executable or there's pathinfo, someone's
** trying to either serve or run a non-CGI file as CGI. Either case
diff -ur thttpd-2.17/libhttpd.h thttpd-2.17-php4/libhttpd.h
--- thttpd-2.17/libhttpd.h Wed May 10 19:19:30 2000+++ thttpd-2.17-php4/libhttpd.h Tue May 30 02:28:46 2000 @@ -69,6 +69,7 @@
char* server_hostname;
int port;
char* cgi_pattern;
+ char* php_pattern;
char* cwd;
int listen4_fd, listen6_fd;
FILE* logfp;
/\lbert
/---------------------------------------------------------------------\
| Albert Siersema aka loonatic | There are no deadlines any deadlier |
| | nor limits more limiting than those | | albert@friendly.net | we set (for) ourselves (la) |\---------------------------------------------------------------------/