PHP4 and CYGWIN
The maintainers of Cywin pulled out the PHP4 modules from the distribution some time ago. When I got my new tablet I am now without an pc baed unix environment. Thought about using a virtual machine... but the thought of managing a 3G file was not that appealing. I have space but... meh
Either way trying to find out how to compile the PHP4 stuff for cygwin. Whew hard to find and I am not happy about it... I have wasted several hours trying to geth this to work. The problem is converting the shared libraries to dll's. No fun... but I found a fix...
Thanks goes out the owner of this Japanese site. The instructions here are good: http://discypus.jp/pukiwiki/pukiwiki.php?cmd=read&page=Cygwin%2Fapache%2Fphp
Special thanks goes to Andrew who posted in the cygwin mailing list -- I cannot agree more that this was very painful -- I followed the same course. Thanks Andrew: http://sources.redhat.com/ml/cygwin/2004-10/msg00502.html
Some extra notes:
- I needed Postgresql support also, and just had to add
"--with-pgsql" to the configure phase and a "-lpq" to the
libphp4.all.a library creation phase.
- Not guaranteed to work with any other options
Code: |
$ grep -A20 '@ apache' setup.ini | grep require requires: cygwin crypt libgdbm4 $ cygcheck -cd cygwin apache crypt libgdbm4 Cygwin Package Information Package Version apache 1.3.29-2 crypt 1.1-1 cygwin 1.5.10-3 libgdbm4 1.8.3-7 |
Code: |
$ cd /usr/local/src/php $ tar jxvf php-4.3.8.tar.bz2 php-4.3.8/ php-4.3.8/ext/ ???? php-4.3.8/README.UNIX-BUILD-SYSTEM php-4.3.8/php4.spec.in $ cd php-4.3.8 $ ./configure --with-apxs=/usr/sbin/apxs --without-mysql --enable-mbstring creating cache ./config.cache checking host system type... i686-pc-cygwin ???? creating main/internal_functions_cli.c +--------------------------------------------------------------------+ | License: | | This software is subject to the PHP License, available in this | | distribution in the file LICENSE. By continuing this installation | | process, you are bound by the terms of this license agreement. | | If you do not agree with the terms of this license, you must abort | | the installation process at this point. | +--------------------------------------------------------------------+ | *** NOTE *** | | The default for register_globals is now OFF! | | | | If your application relies on register_globals being ON, you | | should explicitly set it to on in your php.ini file. | | Note that you are strongly encouraged to read | | http://www.php.net/manual/en/security.registerglobals.php | | about the implications of having register_globals set to on, and | | avoid using it if possible. | +--------------------------------------------------------------------+ Thank you for using PHP |
libphp4.so ------------ libphp4.dll --in-place
Make sure to change the references noted below of libphp4.so to libphp.dll so the install does what it is supposed to.
Code: |
$ sed -i.org 's/libphp4\.so/libphp4.dll/g' Makefile $ diff Makefile.org Makefile |
Code: |
$ make ???? Build complete. (It is safe to ignore warnings about tempnam and tmpnam). $ cd libs $ ls libphp4.a libphp4.la |
dll lresolv (=/lib/libresolv.a) whole-archive, --no-whole-archive
Code: |
$ gcc -shared -o libphp4.dll -Wl,--out-implib=libphp4.dll.a \ -Wl,--export-all-symbols \ -Wl,--whole-archive libphp4.a /bin/cyghttpd.dll \ -Wl,--no-whole-archive -lcrypt -lresolv Creating library file: libphp4.dll.a Info: resolving _ap_user_id by linking to __imp__ap_user_id (auto-import) Info: resolving _ap_group_id by linking to __imp__ap_group_id (auto-import) Info: resolving _ap_user_name by linking to __imp__ap_user_name (auto-import) Info: resolving _ap_max_requests_per_child by linking to __imp__ap_max_requests_ per_child (auto-import) Info: resolving _ap_server_root by linking to __imp__ap_server_root (auto-import ) Info: resolving _top_module by linking to __imp__top_module (auto-import) |
Code: |
$ ls libphp4.a libphp4.dll libphp4.dll.a libphp4.la |
libphp4.dll
Code: |
$ cd .. $ make install Installing PHP SAPI module: apache [activating module `php4' in /etc/apache/httpd.conf] cp libs/libphp4.dll /usr/lib/apache/libphp4.dll chmod 755 /usr/lib/apache/libphp4.dll cp /etc/apache/httpd.conf /etc/apache/httpd.conf.bak cp /etc/apache/httpd.conf.new /etc/apache/httpd.conf rm /etc/apache/httpd.conf.new Installing PHP CLI binary: /usr/local/bin/ Installing PHP CLI man page: /usr/local/man/man1/ Installing PEAR environment: /usr/local/lib/php/ [PEAR] Archive_Tar - installed: 1.1 [PEAR] Console_Getopt - installed: 1.2 [PEAR] PEAR - installed: 1.3.2 Wrote PEAR system config file at: /usr/local/etc/pear.conf You may want to add: /usr/local/lib/php to your php.ini include_path [PEAR] DB - installed: 1.6.2 [PEAR] HTTP - installed: 1.2.2 [PEAR] Mail - installed: 1.1.3 [PEAR] Net_SMTP - installed: 1.2.3 [PEAR] Net_Socket - installed: 1.0.1 [PEAR] XML_Parser - installed: 1.0.1 [PEAR] XML_RPC - installed: 1.1.0 Installing build environment: /usr/local/lib/php/build/ Installing header files: /usr/local/include/php/ Installing helper programs: /usr/local/bin/ program: phpize program: php-config program: phpextdist |
/etc/apache/httpd.conf
Code: |
LoadModule php4_module lib/apache/libphp4.dll AddModule mod_php4.c |
/etc/apache/httpd.conf AddType
Code: |
# # Document types. # <ifmodule mod_mime.c> ???? # for PHP 4.x # AddType application/x-httpd-php .php AddType application/x-httpd-php-source .phps |
|
I have some updates for the latest CYGWIN check this post as well
http://www.smrussell.net/blog/?p=96
For things to work with my config (cygwin=1.5.21, apache=1.3.33, php=4.4) I needed a couple tweaks in the library section titled "dll lresolv (=/lib/libresolv.a) whole-archive, --no-whole-archive" ... The tweaks: (1) need cygwin package "minires" installed for the -lresolv to work, and (2) I don't have "/bin/cyghttpd.dll" so I used "/bin/libhttpd.dll"