在 Windows 下面從原始碼編譯 PHP 的步驟

來源:互聯網
上載者:User
window|編譯|原始碼 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 程式.

相關文章

聯繫我們

該頁面正文內容均來源於網絡整理,並不代表阿里雲官方的觀點,該頁面所提到的產品和服務也與阿里云無關,如果該頁面內容對您造成了困擾,歡迎寫郵件給我們,收到郵件我們將在5個工作日內處理。

如果您發現本社區中有涉嫌抄襲的內容,歡迎發送郵件至: info-contact@alibabacloud.com 進行舉報並提供相關證據,工作人員會在 5 個工作天內聯絡您,一經查實,本站將立刻刪除涉嫌侵權內容。

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.