10/21/2005

Cygwin and PHP (with postgres and mysql) AGAIN!

Filed under: General — russell @ 12:38 pm

Once again I have had to try and get a version of PHP running with Cygwin. You cannot begin to understand the pain. For the details follow the jump:

I started by following my previous blog entry HERE. This all worked great, but I had new install of cygwin which changed alot of how the sockets are handled. In any case I got everything to compile cleanly. Here is my configure options for PHP 4.3.9

Code:
--with-apxs=/usr/sbin/apxs  --enable-magic-quotes --sysconfdir=/etc \
--datadir=/usr/share --with-config-file-path=/etc --bindir=/usr/bin \
--sbindir=/usr/sbin   --with-curl --with-exec-dir=/usr/bin --with-gd \
--with-regex=system --with-gettext --enable-sockets --enable-trans-sid \
--with-pgsql --with-mysql --libdir=/usr/lib --with-zlib \
--with-zlib-dir=/lib --with-png --with-png-dir=/lib --with-jpeg-dir=/lib \
--with-jpeg  --with-pcre=/lib --enable-mbstring

This worked fine. Then when I got to the point where I was compiling the libphp.dll file I had to make lots of changes (you cannot imagine how long it took me to find out how to make these changes). The first was easy I just added the additional libraries for the extra stuff I was compiling into php like -lz -lpq etc. Using the instructions from before it links to the shared cyghttpd.dll, which to begin with was not in /bin. While this lets it compile fine, it cannot load into apache giving a file not found error. OK imagine now... file not found from /usr/lib/apache/libphp4.dll which IS WHERE IT IS SUPPOSED TO BE. Eventually found a nice cygwin utility called cygcheck that list the dll dependencies for any cygwin program/dll.

Code:
cygcheck /usr/lib/apache/libphp4.dll

That revealed that cyghttpd.dll was not where it was supposed to be. So I put it in /bin, great! Apache still crashes onload of php module. After much reading and searching discovered that apache for cygwin now uses libhttpd.dll instead. This is about 30 man hours into it and umpteen compiles. Ok so I got it all fixed up.... heres the code:

Code:
gcc -shared -o libphp4.dll -Wl,--out-implib=libphp4.dll.a \
-Wl,--export-all-symbols \
-Wl,--whole-archive libphp4.a /bin/libhttpd.dll \
-Wl,--no-whole-archive -lcrypt -lc-client  -lpq  -lintl -lpng -lz \
-ljpeg -lcurl -lz -lresolv -lm -lssl -lcrypto -lgdi32 -lwinmm -lz

And guess what still broken..... ARRRRRGGGGGG! This time complaining about "couldn't release memory..." So I rebaseall. Still no dice. After some effort trying to make php work as a cgi, which almost worked (but I forgot it would require me to add the stupid #!/bin/php to ALL my scripts -- kinda defeats the purpose if the production environment is non-cgi). In any case that took a LONG time to figure out. So I decided I would just rebase the stupid libphp4.dll and see if that worked. I started searching for an appropriate rebase command and could not find one... for another LONG time, but eventually found one on a French forum (for postgres dlls). In any case I tried it and viola (no pun intended for any French readers) it started working. Heres the rebase command I used

Code:
rebase -v -b 0x68000000 -d libphp4.dll

No Comments »

No comments yet.

RSS feed for comments on this post.

Leave a comment

Couldn't find your convert utility. Check that you have ImageMagick installed.