Cygwin PHP + Apache on Windows install tips

Karl Brown brown@gnvc.org
Wed Jan 14 20:16:00 GMT 2004


So, you're having trouble installing PHP and Apache under Cygwin on windows?? 

I've just suffered through some pain in setting this up - the following thread was  
useful to me: 
http://www.cygwin.com/ml/cygwin/2003-09/msg01028.html 

More importantly, I actually figured out how to make it work.  Here are the changes  
you have to make if you really want to go this route.  Looking back, I think I would  
have been better off installing a vanilla windows version of apache, and the vanilla  
windows distribution of PHP - that is what most people do and it seems to work  
better.  But if you want to go the hardcore route, see below. 

1) This was done with Apache 1.3.24-5 and PHP 4.2.0-2. 
2) I will assume that apache is already installed and working - even doing that is  
non-trivial, but this page is helpful:  
http://apache.dev.wapme.net/manual/cygwin.html.  Just remember that apache  
cygwin does not accept windows directory names (i.e. d:/foo/bar) - you have to use 
/cygdrive/d/foo/bar 
3) There are bugs in the PHP installer, so we have to work around them.  Luckily, it  
is not that difficult. 

so, the steps: 
0) Stop your apache server 
1) Install the PHP package using the cygwin installer.  This will copy the  
documentation, but you'll notice that the libphp4.dll is somehow missing!  This is the  
first bug. 
2) To correct this bug, you'll have to edit the apache-php.sh script which is stored in  
/etc/postinstall - it should be named 'apache-php.sh.done' at this point. 
3) Open it up, save a backup copy, and replace it with the following: 

=== 
#!/bin/sh 
module=php4 
module_dll=libphp4.dll 
prefix=/usr 
confdir=/etc 
libdir=${prefix}/lib/apache 
echo ${libdir} 
rebase_dlls="${libdir}/${module_dll}  
${prefix}/bin/cygbz21.0.dll ${prefix}/bin/cygcrypto.dll  
${prefix}/bin/cygintl-1.dll ${prefix}/bin/pq.dll  
${prefix}/bin/cygxml2-2.dll ${prefix}/bin/cygz.dll  
${prefix}/bin/cyggdbm.dll ${prefix}/bin/cygssl-0.9.7.dll   
D:\apps\cygwin\bin\cygiconv-2.dll" 
echo ${rebase_dlls} 
cd ${libdir}/new 
${prefix}/sbin/apxs -i -a -n ${module} ${module_dll} 
echo ${module} ${module_dll} 
${prefix}/bin/rebase -d -b 0x68000000 -o 0x10000  
${rebase_dlls} 
#${prefix}/bin/rebase ${rebase_dlls} 

#don't remove module dll 
#rm -f ${libdir}/new/${module_dll} 

=== 
The changes I made were: 
1) add ${prefix}/bin/cygssl-0.9.7.dll  D:\apps\cygwin\bin\cygiconv-2.dll to the dlls to  
be re-based.  This I figured out through trial and error 
2) uncommented the rebase command that had been commented out, and  
commented out the rebase command with bad syntax (no -d -b 0x etc.) 
3) commented the line that removes the libphp4.dll 


Also, rename the file to apache-php-sh 

4) unzip and untar the php distribution - it should be wherever you set Cygwin to  
download packages. 
> cd {wherever this file is located} 
> bunzip2 apache-php-4.3.0-2.tar.bz2 
> tar -xvf apache-php-4.2.0-2.tar 

Within this tarball, you should be able to find libphp4.dll - drop that in /lib/apache 

5) Now, run the post install script: 
$ sh apache-php.sh 

This should now rebase all of the necessary dlls and install the libphp4.dll as a  
shared object. 

6) Now open up your httpd.conf file and add the following lines: 

LoadModule php4_module lib/apache/libphp4.dll 
AddModule mod_php4.c 
AddType application/x-httpd-php .php 

7) now take a sample .php page and start up your apache server - it should be  
working now.  if you want to set up your php as a CGI handler, there are other  
resources on the web for that. 

I hope this helps someone else out there, and hopefully whoever is in charge can fix  
these (relatively) simple problem in the installer script. 

thanks, 
karl brown 
karl at cs.stanford.edu_nospam 
(remove nospam to send) 


--
Unsubscribe info:      http://cygwin.com/ml/#unsubscribe-simple
Problem reports:       http://cygwin.com/problems.html
Documentation:         http://cygwin.com/docs.html
FAQ:                   http://cygwin.com/faq/



More information about the Cygwin mailing list