install.windows.building.html
来自「php的帮助文档,涉及到PHP的案例和基本语法,以及实际应用内容」· HTML 代码 · 共 628 行 · 第 1/2 页
HTML
628 行
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd"><html> <head> <title>Building from source</title> <meta http-equiv="content-type" content="text/html; charset=UTF-8"> </head> <body><div style="text-align: center;"> <div class="prev" style="text-align: left; float: left;"><a href="install.windows.xitami.html">Xitami on Microsoft Windows</a></div> <div class="next" style="text-align: right; float: right;"><a href="install.windows.extensions.html">Installation of extensions on Windows</a></div> <div class="up"><a href="install.windows.html">Installation on Windows systems</a></div> <div class="home"><a href="index.html">PHP Manual</a></div></div><hr /><div id="install.windows.building" class="sect1"> <h2 class="title">Building from source</h2> <p class="para"> This chapter teaches how to compile PHP from sources on windows, using Microsoft's tools. To compile PHP with cygwin, please refer to <a href="install.unix.html" class="xref">Installation on Unix systems</a>. </p> <div id="install.windows.building.quick-guide" class="sect2"> <h3 class="title">Quick Guide to Building On Windows</h3> <p class="para"> This step-by-step quick-start guide was written in March of 2008, running Windows XP Service Pack 2 with all the latest updates and building PHP 5.2.5 and PHP 5.3. Experiences using different tools may differ. </p> <ol class="orderedlist"> <li class="listitem"> <p class="para"> Download and install: </p> <ul class="itemizedlist"> <li class="listitem"> <span class="simpara"> <a href="http://www.microsoft.com/express/download/" class="link external">» Microsoft Visual C++ 2008 Express Edition</a> </span> </li> <li class="listitem"> <span class="simpara"> <a href="http://www.microsoft.com/downloads/details.aspx?FamilyID=E6E1C3DF-A74F-4207-8586-711EBE331CDC" class="link external">» Windows SDK for Windows Server 2008 and .NET Framework 3.5</a> </span> </li> </ul> </li> <li class="listitem"> <span class="simpara"> Copy <var class="filename">C:\Program Files\Microsoft SDKs\Windows\v6.1\Include\WinResrc.h</var> to <var class="filename">C:\Program Files\Microsoft SDKs\Windows\v6.1\Include\winres.h</var>. </span> </li> <li class="listitem"> <span class="simpara"> Create the directory <var class="filename">C:\work</var>. </span> </li> <li class="listitem"> <span class="simpara"> Download <a href="http://www.php.net/extra/win32build.zip" class="link external">» the Windows build tools</a> and unzip the contents into <var class="filename">C:\work</var>. </span> </li> <li class="listitem"> <span class="simpara"> Create the directory <var class="filename">C:\usr\local\lib</var>. Copy the <var class="filename">C:\work\win32build\bin\bison.simple</var> into the new directory. </span> </li> <li class="listitem"> <span class="simpara"> Download <a href="http://www.php.net/extra/bindlib_w32.zip" class="link external">» the Windows DNS resolver library</a> and unzip the contents into <var class="filename">C:\work</var>. </span> </li> <li class="listitem"> <span class="simpara"> Open <var class="filename">C:\work\bindlib_w32\bindlib.dsw</var>. If and when asked whether to update the project, choose Yes. Choose either Debug or Release configuration in the top toolbar, then choose Build => Build Solution. </span> </li> <li class="listitem"> <span class="simpara"> Obtain a copy of the PHP source and extract it into the <var class="filename">C:\work</var> directory. At this point, that directory should look something like this: </span> <div class="example-contents"><pre><div class="cdata"><pre>+-C:\work| +-bindlib_w32| | +-Debug| | | +-resolv.lib| | | +-...| | +-...| +-win32build| | +-bin| | +-include| | +-lib| +-php-5.2.5| | +-build| | +-win32| | +-...</pre></div></pre></div> </li> <li class="listitem"> <span class="simpara"> Open a shell using the Visual Studio 2008 Command Prompt shortcut in the Start menu. </span> </li> <li class="listitem"> <span class="simpara"> Execute the command: </span> <div class="example-contents"><pre><div class="cdata"><pre>C:\Program Files\Microsoft Visual Studio 9.0\VC> set "PATH=C:\work\win32build\bin;%PATH%"C:\Program Files\Microsoft Visual Studio 9.0\VC></pre></div></pre></div> </li> <li class="listitem"> <span class="simpara"> Enter the <var class="filename">C:\work\php-5.2.5</var> directory. </span> </li> <li class="listitem"> <span class="simpara"> Run <strong class="command">cscript /nologo win32\build\buildconf.js</strong>. </span> </li> <li class="listitem"> <span class="simpara"> Run <strong class="command">cscript /nologo configure.js --disable-all --enable-cli --enable-cgi --enable-object-out-dir=.. --disable-ipv6</strong>. To enable debugging, add <strong class="command">--enable-debug</strong> to the end. </span> </li> <li class="listitem"> <span class="simpara"> Run <strong class="command">nmake</strong>. </span> </li> <li class="listitem"> <span class="simpara"> If all went well, there will now be a working PHP CLI executable at <var class="filename">C:\work\Debug_TS\php.exe</var>, or <var class="filename">C:\work\Release_TS\php.exe</var>. </span> </li> </ol> </div> <div id="install.windows.building.environment" class="sect2"> <h3 class="title">Build Environment</h3> <p class="para"> To compile and build PHP you need a Microsoft Development Environment. The following environments are supported: </p> <ul class="itemizedlist"> <li class="listitem"> <span class="simpara"> Microsoft Visual C++ 6.0 (official) </span> </li> <li class="listitem"> <span class="simpara"> Microsoft Visual C++ .NET </span> </li> <li class="listitem"> <span class="simpara"> Microsoft Visual C++ 2005, Windows Platform SDK and .NET Framework SDK (current) </span> </li> </ul> <p class="para"> While VC6 (Microsoft Visual C++ 6.0) is used to perform official Windows builds, it can no longer be downloaded from Microsoft's website. New users seeking to build PHP for free must use Microsoft Visual C++ 2005 Express Edition and its auxiliary components. </p> <div id="install.windows.building.environment.express2005" class="sect3"> <h4 class="title">Setting up Microsoft Visual C++ 2005 Express</h4> <blockquote><p><b class="note">Note</b>: <span class="simpara"> Combined, these components are very large and will require over one gigabyte of disk space. </span> </p></blockquote> <p class="para"> Setting up Microsoft Visual C++ 2005 Express is rather involved, and requires the installation of three separate packages and various compatibility changes. Be sure to keep track of the paths in which these programs are installed into. Download and install the following programs: </p> <ul class="itemizedlist"> <li class="listitem"> <span class="simpara"> <a href="http://msdn.microsoft.com/vstudio/express/visualc/" class="link external">» Microsoft Visual C++ 2005 Express</a> </span> </li> <li class="listitem"> <span class="simpara"> <a href="http://www.microsoft.com/downloads/details.aspx?FamilyId=0BAF2B35-C656-4969-ACE8-E4C0C0716ADB" class="link external">» Microsoft Windows Server 2005 Platform SDK</a> </span> </li> <li class="listitem"> <span class="simpara"> <a href="http://www.microsoft.com/downloads/details.aspx?FamilyId=FE6F2099-B7B4-4F47-A244-C96D69C35DEC" class="link external">» .NET Framework 2.0 Software Development Kit</a> </span> </li> </ul> <p class="para"> There are a few post-installation steps: </p> <ul class="itemizedlist"> <li class="listitem"> <span class="simpara"> <a href="http://msdn2.microsoft.com/en-us/library/ms235626(VS.80).aspx" class="link external">» MSVC 2005 Express must be configured to use Windows Platform SDK</a>. It is not necessary to perform step two, as PHP does not use the graphical user interface. </span> </li> <li class="listitem"> <span class="simpara"> Windows Platform SDK contains a file named <var class="filename">WinResrc.h</var> usually in <var class="filename">Include</var> folder inside the SDK's installation directory. This needs to be copied and renamed to <var class="filename">winres.h</var>, the name PHP uses for the file. </span> </li> </ul> <p class="para"> Finally, when using MSVC 2005 Express from the command line, several environment variables must be set up. <var class="filename">vsvars32.bat</var> usually found in <var class="filename">C:\Program Files\Microsoft Visual Studio 8\Common7\Tools</var> (search for the file if otherwise) contains these declarations. The <var class="varname">PATH</var>, <var class="varname">INCLUDE</var> and <var class="varname">LIB</var> environment variables need the corresponding <var class="filename">bin</var>, <var class="filename">include</var> and <var class="filename">lib</var> directories of the two newly installed SDKs added to them. </p> <blockquote><p><b class="note">Note</b>: <span class="simpara"> The .NET SDK paths may already be present in the <var class="filename">vsvars32.bat</var> file, as this SDK installs itself into the same directory as Microsoft Visual C++ 2005 Express. </span> </p></blockquote> </div> </div> <div id="install.windows.building.libraries" class="sect2"> <h3 class="title">Libraries</h3> <p class="para"> To extract the downloaded files you will also need a ZIP extraction utility. Windows XP and newer already include this functionality built-in. </p> <p class="para"> Before you get started, you have to download: </p> <ul class="itemizedlist"> <li class="listitem"> <span class="simpara"> the win32 buildtools from the PHP site at <a href="http://www.php.net/extra/win32build.zip" class="link external">» http://www.php.net/extra/win32build.zip</a>. </span> </li> <li class="listitem"> <span class="simpara"> the source code for the DNS name resolver used by PHP from <a href="http://www.php.net/extra/bindlib_w32.zip" class="link external">» http://www.php.net/extra/bindlib_w32.zip</a>. This is a replacement for the <var class="filename">resolv.lib</var> library included in <var class="filename">win32build.zip</var>. </span> </li> <li class="listitem"> <span class="simpara"> If you plan to compile PHP as a Apache module you will also need the <a href="http://www.apache.org/dist/httpd/" class="link external">» Apache sources</a>. </span> </li> </ul> <p class="simpara"> Finally, you are going to need the source to PHP itself. You can get the latest development version using <a href="http://www.php.net/anoncvs.php" class="link external">» anonymous CVS</a>, a <a href="http://snaps.php.net/" class="link external">» snapshot</a> or the most recent released <a href="http://www.php.net/downloads.php" class="link external">» source</a> tarball. </p> </div> <div id="install.windows.building.install" class="sect2"> <h3 class="title">Putting it all together</h3> <p class="para">
⌨️ 快捷键说明
复制代码Ctrl + C
搜索代码Ctrl + F
全屏模式F11
增大字号Ctrl + =
减小字号Ctrl + -
显示快捷键?