将 PHP 5.3.3 从源代码编译到 Apache

发布于 2024-09-12 23:02:06 字数 1655 浏览 6 评论 0原文

刚刚从源代码(win32)编译了 5.3.3。 尝试测试一些 header() 内容,但看起来它不适用于 CLI sapi。 任何关于将编译后的源代码作为模块放入 apache 的好文档,就像我通常对预编译模块所做的那样。

基本上我的测试是从 CLI 进行的,

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

我从 headers_list() 中得到一个空数组,所以我需要将这个内置源放入 apache 中,以便我从 headers_list() 中得到响应。

预先感谢各位。

------- 更新 ------

配置命令,但还没有 apache? 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       |
-------------

-----第二次更新----

下载的apache,将其粘贴在 ../apache 中并尝试以下命令但找不到标头。

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

---- 第三次更新 ---

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

感谢您的链接

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

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(2

离线来电— 2024-09-19 23:02:06

PHP cli SAPI 并不是真正用于发送 HTTP 标头;而是用于发送 HTTP 标头。它的目的是从命令行使用。

如果要将 PHP 与 Apache 一起使用,则必须编译 Apache 模块 SAPI 或 CGI SAPI。

要编译 Apache 2.2 模块,您必须拥有 Apache 库并分别在 %LIB% 和 %INCLUDE% 中包含目录,并使用:

--enable-apache2-2handler

请注意,您采用 Apache 模块路线,必须使用相同版本的 C 运行时来编译它Apache 二进制文件使用的库。原因是 PHP 必须能够分配内存并将这些指针传递给 Apache,以便它释放它们,反之亦然,并且为了正确发生这一点,版本必须相同。因此,例如,如果您编译(或从某处下载)使用 Visual C++ 9 编译的 Apache,则必须使用 Visual C++ 9 来编译 PHP。

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.

深府石板幽径 2024-09-19 23:02:06

输出应该比您在 http://pastebin.com/qhFVR8A3
最有可能出现消息无法找到 apache2.2 库/头,这意味着配置脚本无法找到以下文件之一:

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

将这些文件复制到 php-build include/library 路径或使用 --with-extra-includes--with-extra-libs指向适当的目录。

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.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文