install.windows.building.html
来自「php的帮助文档,涉及到PHP的案例和基本语法,以及实际应用内容」· HTML 代码 · 共 628 行 · 第 1/2 页
HTML
628 行
After downloading the required packages you have to extract them in a proper place: <ul class="itemizedlist"> <li class="listitem"> <span class="simpara"> Create a working directory where all files end up after extracting, e.g: <var class="filename">C:\work</var>. </span> </li> <li class="listitem"> <span class="simpara"> Create the directory <var class="filename">win32build</var> under your working directory (<var class="filename">C:\work</var>) and unzip <var class="filename">win32build.zip</var> into it. </span> </li> <li class="listitem"> <span class="simpara"> Create the directory <var class="filename">bindlib_w32</var> under your working directory (<var class="filename">C:\work</var>) and unzip <var class="filename">bindlib_w32.zip</var> into it. </span> </li> <li class="listitem"> <span class="simpara"> Extract the downloaded PHP source code into your working directory (<var class="filename">C:\work</var>). </span> </li> <li class="listitem"> <span class="simpara"> Build the libraries you are going to need (or download the binaries if available) and place the headers and libs in the <var class="filename">C:\work\win32build\include</var> and <var class="filename">C:\work\win32build\lib</var> directories, respectively. </span> </li> <li class="listitem"> <span class="simpara"> If you don't have cygwin installed with bison and flex, you also need to make the <var class="filename">C:\work\win32build\bin</var> directory available in the PATH, so that thoses tools can be found by the configure script. </span> </li> </ul> Following this steps your directory structure looks like this: <div class="example-contents"><pre><div class="cdata"><pre>+--C:\work| || +--bindlib_w32| | || | +--arpa| | || | +--conf| | || | +--...| || +--php-5.x.x| | || | +--build| | || | +--...| | || | +--win32| | || | +--...| || +--win32build| | || | +--bin| | || | +--include| | || | +--lib</pre></div> </pre></div> </p> <p class="para"> If you aren't using <a href="http://www.cygwin.com/" class="link external">» Cygwin</a>, you must also create the directories <var class="filename">C:\usr\local\lib</var> and then copy <var class="filename">bison.simple</var> from <var class="filename">C:\work\win32build\bin </var> to <var class="filename">C:\usr\local\lib</var>. </p> <blockquote><p><b class="note">Note</b>: <span class="simpara"> If you want to use PEAR and the comfortable command line installer, the CLI-SAPI is mandatory. For more information about PEAR and the installer read the documentation at the <a href="http://pear.php.net/manual/" class="link external">» PEAR</a> website. </span> </p></blockquote> </div> <div id="install.windows.building.resolvlib" class="sect2"> <h3 class="title">Build resolv.lib</h3> <p class="para"> You must build the <var class="filename">resolv.lib</var> library. Decide whether you want to have debug symbols available (bindlib - Win32 Debug) or not (bindlib - Win32 Release), but please remember the choice you made, because the debug build will only link with PHP when it is also built in debug mode. Build the appropriate configuration: <ul class="itemizedlist"> <li class="listitem"> <span class="simpara"> For GUI users, launch VC++, by double-clicking in <var class="filename">C:\work\bindlib_w32\bindlib.dsw</var>. Then select Build=>Rebuild All. </span> </li> <li class="listitem"> <span class="simpara"> For command line users, make sure that you either have the C++ environment variables registered, or have run <strong class="command">vcvars.bat</strong>, and then execute one of the following commands: </span> <ul class="itemizedlist"> <li class="listitem"> <span class="simpara"> <strong class="command">msdev bindlib.dsp /MAKE "bindlib - Win32 Debug"</strong> </span> </li> <li class="listitem"> <span class="simpara"> <strong class="command">msdev bindlib.dsp /MAKE "bindlib - Win32 Release"</strong> </span> </li> </ul> </li> </ul> At this point, you should have a usable <var class="filename">resolv.lib</var> in either your <var class="filename">C:\work\bindlib_w32\Debug</var> or <var class="filename">Release</var> subdirectories. Copy this file into your <var class="filename">C:\work\win32build\lib</var> directory over the file by the same name found in there. </p> </div> <div id="install.windows.building.new" class="sect2"> <h3 class="title">Building PHP using the new build system [PHP >=5 only]</h3> <p class="para"> This chapter explains how to compile PHP >=5 using the new build system, which is CLI-based and very similar with the main PHP's Unix build system. </p> <blockquote><p><b class="note">Note</b>: This build system isn't available in PHP 4. Please refer to <a href="install.windows.building.html" class="xref">Building from source</a> instead. <br /> </p></blockquote> <p class="para"> Before starting, be sure you have read <a href="install.windows.building.html" class="xref">Building from source</a> and you have built all needed libraries, like <a href="http://www.xmlsoft.org/" class="link external">» Libxml</a> or <a href="http://icu.sourceforge.net/" class="link external">» ICU</a> (needed for PHP >= 6). </p> <p class="para"> First you should open a Visual Studio Command Prompt, which should be available under the Start menu. A regular Command Prompt window shouldn't work, as probably it doesn't have the necessary environment variables set. Then type something like <strong class="command">cd C:\work\php-5.x.x</strong> to enter in the PHP source dir. Now you are ready to start configuring PHP. </p> <p class="para"> The second step is running the <strong class="command">buildconf</strong> batch file to make the configure script, by scanning the folder for <var class="filename">config.w32</var> files. By default this command will also search in the following directories: <var class="filename">pecl; ..\pecl; pecl\rpc; ..\pecl\rpc</var>. Since PHP 5.1.0, you can change this behaviour by using the <i>--add-modules-dir</i> argument (e.g. <strong class="command">cscript /nologo win32/build/buildconf.js --add-modules-dir=../php-gtk2 --add-modules-dir=../pecl</strong>). </p> <p class="para"> The third step is configuring. To view the list of the available configuration options type <strong class="command">cscript /nologo configure.js --help</strong>. After choosing the options that you will enable/disable, type something like: <strong class="command">cscript /nologo configure.js --disable-foo --enable-fun-ext</strong>. Using <i>--enable-foo=shared</i> will attempt to build the 'foo' extension as a shared, dynamically loadable module. </p> <p class="para"> The last step is compiling. To achieve this just issue the command <strong class="command">nmake</strong>. The generated files (e.g. .exe and .dll) will be placed in either <var class="filename">Release_TS</var> or <var class="filename">Debug_TS</var> directories (if built with Thread safety), or in the <var class="filename">Release</var> or <var class="filename">Debug</var> directories otherwise. </p> <p class="para"> Optionally you may also run PHP's test suite, by typing <strong class="command">nmake test</strong>. If you want to run just a specific test, you may use the 'TESTS' variable (e.g. <strong class="command">nmake /D TESTS=ext/sqlite/tests test</strong> - will only run sqlite's tests). To delete the files that were created during the compilation, you can use the <strong class="command">nmake clean</strong> command. </p> <p class="para"> A very useful configure option to build snapshots is <i>--enable-snapshot-build</i>, which add a new compiling mode (<strong class="command">nmake build-snap</strong>). This tries to build every extension available (as shared, by default), but it will ignore build errors in individual extensions or SAPI. </p> </div> <div id="install.windows.building.dsw" class="sect2"> <h3 class="title">Building PHP using DSW files [PHP 4]</h3> <p class="para"> Compiling PHP using the DSW files isn't supported as of PHP 5, as a much <a href="install.windows.building.html#install.windows.building.new" class="link">more flexible system was made available</a>. Anyway, you can still use them, but keep in mind that they are not maintained very often, so you can have compiling problems. To compile PHP 4 for windows, this is the only available way though. </p> <div id="install.windows.building.dsw.configure" class="sect3"> <h4 class="title">Configure MVC ++</h4> <p class="para"> The first step is to configure MVC++ to prepare for compiling. 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. Your entries should look like this: <ul class="itemizedlist"> <li class="listitem"> <span class="simpara"> Executable files: <var class="filename">C:\work\win32build\bin</var>, Cygwin users: <var class="filename">C:\cygwin\bin</var> </span> </li> <li class="listitem"> <span class="simpara"> Include files: <var class="filename">C:\work\win32build\include</var> </span> </li> <li class="listitem"> <span class="simpara"> Library files: <var class="filename">C:\work\win32build\lib</var> </span> </li> </ul> </p> </div> <div id="install.windows.building.dsw.compile" class="sect3"> <h4 class="title">Compiling</h4> <p class="simpara"> The best way to get started is to build the CGI version: </p> <ul class="itemizedlist"> <li class="listitem"> <span class="simpara"> For GUI users, launch VC++, and then select File => Open Workspace and select <var class="filename">C:\work\php-4.x.x\win32\php4ts.dsw</var>. Then select Build=>Set Active Configuration and select the desired configuration, either <i>php4ts - Win32 Debug_TS</i> or <i>php4ts - Win32 Release_TS</i>. Finally select Build=>Rebuild All. </span> </li> <li class="listitem"> <span class="simpara"> For command line users, make sure that you either have the C++ environment variables registered, or have run <strong class="command">vcvars.bat</strong>, and then execute one of the following commands from the <var class="filename">C:\work\php-4.x.x\win32</var> directory: </span> <ul class="itemizedlist"> <li class="listitem"> <span class="simpara"> <strong class="command">msdev php4ts.dsp /MAKE "php4ts - Win32 Debug_TS"</strong> </span> </li> <li class="listitem"> <span class="simpara"> <strong class="command">msdev php4ts.dsp /MAKE "php4ts - Win32 Release_TS"</strong> </span> </li> <li class="listitem"> <span class="simpara"> At this point, you should have a usable <var class="filename">php.exe</var> in either your <var class="filename">C:\work\php-4.x.x\Debug_TS</var> or <var class="filename">Release_TS</var> subdirectories. </span> </li> </ul> </li> </ul> <p class="simpara"> It is possible to do minor customization to the build process by editing the <var class="filename">main/config.win32.h</var> file. For example you can change the default location of <var class="filename">php.ini</var>, the built-in extensions, and the default location for your extensions. </p> <p class="simpara"> Next you may want to build the CLI version which is designed to use <a href="features.commandline.html" class="link">PHP from the command line</a>. The steps are the same as for building the CGI version, except you have to select the <i>php4ts_cli - Win32 Debug_TS</i> or <i>php4ts_cli - Win32 Release_TS</i> project file. After a successful compiling run you will find the <var class="filename">php.exe</var> in either the directory <var class="filename">Release_TS\cli\</var> or <var class="filename">Debug_TS\cli\</var>. </p> <p class="simpara"> In order to build the SAPI module (<var class="filename">php4isapi.dll</var>) for integrating PHP with Microsoft IIS, set your active configuration to <var class="filename">php4isapi-whatever-config</var> and build the desired dll. </p> </div> </div></div><hr /><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></body></html>
⌨️ 快捷键说明
复制代码Ctrl + C
搜索代码Ctrl + F
全屏模式F11
增大字号Ctrl + =
减小字号Ctrl + -
显示快捷键?