首页 > 开发 > PHP > 正文

在 Windows 下面从源代码编译 PHP 的步骤

2024-05-04 22:57:59
字体:
来源:转载
供稿:网友
building from source
从源代码建立

before getting started, it is worthwhile answering the question: "why is building on windows so hard?" two reasons come to

mind:

在开始前,我们来回答一个问题:“为什么在 windows 下编译 php 如此困难?“,2个注意的原因是:

windows does not (yet) enjoy a large community of developers who are willing to freely share their source. as a direct

result, the necessary investment in infrastructure required to support such development hasnt been made. by and large, what

is available has been made possible by the porting of necessary utilities from unix. dont be surprised if some of this

heritage shows through from time to time.

windows 不是一个大量愿意免费共享他们代码的开发团体。直接导致支持这些开发的基础投资没有建立,而unix 可能已经建立了。

pretty much all of the instructions that follow are of the "set and forget" variety. so sit back and try follow the

instructions below as faithfully as you can.

下面的大多数好东西是"set and forget".所以请尽可能严格按照下面的步骤进行。

preparations
before you get started, you have a lot to download....

准备:
在开始前,你需要下载许多东西!!


for starters, get the cygwin toolkit from the closest cygnus mirror site. what you are looking for is cygwin.exe file. this

will provide you most of the popular gnu utilities used by the build process.
http://sources.redhat.com/cygwin/download.html
开始,从最近的 cygnus 的镜像站点获取 cygwin 工具箱。你要找的是 cygwin.exe 文件。他提供了大多数流行的 gnu 工具用于编译过程:


download the rest of the build tools you will need from the php site at http://www.php.net/extra/win32build.zip.

下载其他的编译需要的工具,从 php 的站点:

get the source code for the dns name resolver used by php at http://www.php.net/extra/bindlib_w32.zip. this is a replacement

for the resolv.lib library included in win32build.zip.

获得 php 使用的用于 dns 名字解析的源代码。替换 win32build.zip 里面的 resolv.lib 文件

if you dont already have an unzip utility, you will need one. a free version is available from infozip.

如果你没有解压缩工具,你需要下载一个。 infozip 有一个免费的!!

finally, you are going to need the source to php 4 itself. you can get the latest development version using anonymous cvs. if

you get a snapshot or a source tarball, you not only will have to untar and ungzip it, but you will have to convert the bare

linefeeds to crlfs in the *.dsp and *.dsw files before microsoft visual c++ will have anything to do with them.

最后,你需要 php 的源代码本身。你可以使用匿名 cvs 获得最新的开发版本。如果你得到的是一个 snapshot 或者一个源代码 tarball, 你

不仅需要展开它, 而且在 microsoft visual c++ 可以处理所有东西前,你需要转换在 *.dsp 和 *.dws 文件里的空的换行符为回车换行符号



note: place the zend and tsrm directories inside the php4 directory in order for the projects to be found during the build

process.

注意:放置 zend 和 tstm 目录在 php4 目录里面,使得工程在建立期间可以找到他们

putting it all together

把他们放在一起

follow the instructions for installing the unzip utility of your choosing.

按照下面的步骤来安装你选择的展开系统

execute cygwin.exe and follow the installation instructions. if you choose to install to a path other than c:cygnus, let the

build process know by setting the cygwin environment variable. on windows 95/98 setting an environment variable can be done

by placing a line in your autoexec.bat. on windows nt, go to my computer => control panel => system and select the

environment tab.

运行 cygwin.exe,按照安装步骤进行。如果你选择安装到一个不是 c:cygnus 的路径,必须通过设置 cygwin 环境变量通知建立程序。在

windows 95/98 下,设置环境变量可以通过在 autoexec.bat 里加入一行来做到!在 window nt,打开 我的电脑 => 系统 然后选择化镜变量标

签。


warning
make a temporary directory for cygwin to use, otherwise many commands (particularly bison) will fail. on windows 95/98, mkdir

c:tmp. for windows nt, mkdir %systemdrive%tmp.

警告:
建立一个 cygwin使用的临时目录。否则许多命令(特别是 bison)会失败。在 windows 95/98 下,建立目录 mkdir c:tmp, 在 windows nt

下 mkdir %systemdrive%tmp。


make a directory and unzip win32build.zip into it.

建立一个目录,展开 win32build.zip 到里面

launch microsoft visual c++, and from the menu select tools => options. in the dialog, select the directories tab.

sequentially change the dropdown to executables, includes, and library files, and ensure that cygwinbin, win32buildinclude,

and win32buildlib are in each list, respectively. (to add an entry, select a blank line at the end of the list and begin

typing). typical entries will look like this:

运行 microsoft visual c++,从菜单里选择 tools => option. 在对话框里,选择 directories(路径) 标签.向下移动到 executables(可执

行), includes(包含文件), 和 library(库文件) 文件处,确认 cygwinbin,win32buildinclude,和win32buildlib 分别在每个列表里面。(

要增加一个入口,先则列表尾部的空行,然后敲入).典型的结果如下:

c:cygnusbin

c:php-win32buildinclude

c:php-win32buildlib

press ok, and exit out of visual c++.

按 ok 键。退出 visual c++

make another directory and unzip bindlib_w32.zip into it. decide whether you want to have debug symbols available (bindlib -

win32 debug) or not (bindlib - win32 release). build the appropriate configuration:

建立另外一个目录,展开 blindlib_w32.zip 到里面。确定是否你想要调试符号。建立恰当的配置。


for gui users, launch vc++, and then select file => open workspace and select bindlib. then select build=>set active

configuration and select the desired configuration. finally select build=>rebuild all.

对于 gui 用户,运行 vc++, 选择 file => open workspace, 然后选择 bindlib. 然后选择 build=>set active configuration ,选择想要的

配置。最后选择 build => rebuild all.

for command line users, make sure that you either have the c++ environment variables registered, or have run vcvars.bat, and

then execute one of the following:

对于命令行用户,确认你已经注册 c++环境变量或者已经运行了 vcvars.bat.然后运行下面的任何一个

msdev bindlib.dsp /make "bindlib - win32 debug"

msdev bindlib.dsp /make "bindlib - win32 release"

at this point, you should have a usable resolv.lib in either your debug or release subdirectories. copy this file into your

win32buildlib directory over the file by the same name found in there.

这时,你获得一个可用的 resolv.lib 在你的 debug 或者 release 子目录下面。复制这个文件到你的 win32buildlib 目录,覆盖那里的同

名的文件。

compiling

编译

the best way to get started is to build the standalone/cgi version.

开始最好建立独立/cgi版本


for gui users, launch vc++, and then select file => open workspace and select php4ts. then select build=>set active

configuration and select the desired configuration. finally select build=>rebuild all.

对于 gui 用户,运行 vc++,选择 file => open workspace 选择 php4ts,然后选择 build => set active configuration, 选择想要的配置。

最后选择 build => rebuild all.

for command line users, make sure that you either have the c++ environment variables registered, or have run vcvars.bat, and

then execute one of the following:

对于命令行用户,确认你已经注册 c++环境变量或者已经运行了 vcvars.bat.然后运行下面的任何一个

msdev php4ts.dsp /make "php4ts - win32 debug_ts"

msdev php4ts.dsp /make "php4ts - win32 release_ts"

at this point, you should have a usable php.exe in either your debug_ts or release_ts subdirectories.
这时,你可以得到可用的 php.exe 在你的 debug_ts 或者 release_ts 子目录下面。

repeat the above steps with php4isapi.dsp (which can be found in sapiisapi) in order to build the code necessary for

integrating php with microsoft iis.

对于 phpisapi.dsp 重复上面的步骤(在 sapiisapi 里面可以找到).建立 microsoft iis 的 isapi 程序.
发表评论 共有条评论
用户名: 密码:
验证码: 匿名发表