views:

160

answers:

2

Just compiled 5.3.3 from source (win32). Trying to test some header() stuff but it looks like it won't work with CLI sapi. Any good docs on putting your compiled source into apache as a module, just like i'd normally do with the pre-compiled module.

Basically my test would be from CLI

php -r "header('Content-Type: text/plain', true, 404); var_dump(headers_list());"

I get an empty array from headers_list() so I need to get this built source into apache so that i get a response from headers_list().

Thanks in advance guys.

------- UPDATE ------

Configure command, yet no apache just yet? http://pastebin.com/qhFVR8A3:

E:\phpsdk\bin\php53dev\vc9\x86\php5.3.3>configure --disable-all --enable-cli --enable-apache2-2handler --enable-apache2-2filter

Enabled SAPI:
-------------
| Sapi Name |
-------------
| cli       |
-------------

----- 2nd UPDATE ----

Downloaded apache, stuck it in ../apache and tried the following command but can't find the headers.

http://pastebin.com/XyrzuZvu:

E:\phpsdk\bin\php53dev\vc9\x86\php5.3.3>
configure --disable-all --enable-cli --enable-apache2-2handler=../apache --enable-apache2-2filter --enable-cgi

---- 3rd Update ---

Enabled SAPI:
--------------------
| Sapi Name        |
--------------------
| apache2_2filter  |
| apache2_2handler |
| cgi              |
| cli              |
--------------------

I have it working now.
E:\phpsdk\bin\php53dev\vc9\x86\php5.3.3>configure --disable-all --enable-cli --enable-apache2-2handler --enable-apache2-2filter --enable-cgi --with-extra-includes=E:\phpsdk\bin\php53dev\vc9\x86\apache\include --with-extra-libs=E:\phpsdk\bin\php53dev\vc9\x86\apache\lib

Thanks for the link

+2  A: 

The PHP cli SAPI is not really meant to send HTTP headers; its purpose is to be used from the command line.

If you want to use PHP with Apache, you must compile the Apache module SAPI or the CGI SAPI.

To compile the Apache 2.2 module you must have the Apache libraries and include directories in %LIB% and %INCLUDE%, respectively, and use:

--enable-apache2-2handler

Notice that you go the Apache module route, you must compile it with against same version of the C runtime library that the Apache binaries use. The reason is that PHP must be able to allocate memory and pass those pointers to Apache for it to free them and vice-versa, and for that to happen correctly, the versions must be the same. So, for example, if you compiled (or downloaded from somewhere) Apache compiled with Visual C++ 9, you must use Visual C++ 9 to compile PHP.

Artefacto
Yes i'm aware of this, but i'm looking fro the relevant options in configure to get apache SAPI enabled. See my updated post.
Paul Dragoonis
@Paul I've added the relevant information.
Artefacto
I've downloaded apache into ../apache from my build dir shown in latest pastebin. Can you specify where %LIB% and %INCLUDE% are ?
Paul Dragoonis
@Paul Those are environment variables. Use `SET LIB=%LIB%;X:\path\to\apache2.2\lib` and `SET INCLUDE=%INCLUDE%;X:\path\to\apache2.2\include` or use the configure options like VolkerK says.
Artefacto
I indeed have that /include/ directory, but not the /lib/ directory. I'm downloading from: http://apache.mirror.anlx.net/httpd/httpd-2.2.16-win32-src.zip
Paul Dragoonis
@Paul That directory is created after Apache is compiled. Those are just the sources.
Artefacto
@Paul check these binaries for vc9: http://www.apachelounge.com/download/binaries/httpd-2.2.16-win32-x86-ssl.zip If you are compiling a debug version of PHP, you'll have to compile yourself a debug version of Apache, because I doubt you'll find debug binaries on the Internet.
Artefacto
Perfect link though, i have the necessary libs for the SAPI to be enabled.
Paul Dragoonis
+1  A: 

There should be a lot more output than the few lines you've posted at http://pastebin.com/qhFVR8A3
Most likely there was the message Could not find apache2.2 libraries/headers which means that the configure script could not find at least one of the following files:

  • httpd.h
  • libhttpd.lib
  • libapr-1.lib
  • libaprutil-1.lib

Either copy those files to the php-build include/library path or use --with-extra-includes and --with-extra-libs to point to the appropriate directories.

VolkerK
Looking here can u tell me the appropriate directories to fire --extra-includes and --extra-libs at ? http://apache.mirror.anlx.net/httpd/httpd-2.2.16-win32-src.zip
Paul Dragoonis