Build your own PHP (php5.3 +) on the windows platform)

Source: Internet
Author: User
Tags vc9

This is a translation article, see: https://wiki.php.net/internals/windows/stepbystepbuild

By the way, wiki.php.net has a lot of wonderful content. Do not miss it if you want to know more about php :)

Preparations

Three preparations are required for compiling php on windows:

1. Suitable compiling environment, including installing a compiler, correct SDK, and corresponding binary tools

2. Compile the third library and header file required by PHP.

3. PHP source code

Build Environment

This is the most difficult part to compile php on the windows platform, because the establishment of such a compilation environment requires a lot of disk space, there may be several GB

Requirements:

  • Microsoft Visual C ++. The official PHP version supports VC ++ 6.0 and VC ++ 9.0 (VC ++ 2008), and Express. MinGW and other compilers are not supported.
  • Correct windows SDK or Platform SDK, SDK needs to correspond to VC version, see https://wiki.php.net/internals/windows/windowssdk
  • Binary tools used for compilation, see http://windows.php.net/downloads/php-sdk/

Note:

The latest php5.5 can be compiled using VC ++ 9 or VC ++ 11, but 5.5 has not yet been officially released.

If you are using VC6, install the Windows Server Feb.2003 SDK. If you are using VC9, install SDK6.1.

Build Steps

1. Install vs2008

2. Install windows sdk 6.1

3. Get the php 5.3 source code and get the snapshot from this address (do not unzip it first)

4. Create the c: \ php-sdk folder.

5. Decompress binary-tools.zip to the c: \ php-sdk folder. Binary-tools.zip can be obtained from this place (http://windows.php.net/downloads/php-sdk ). After decompression, the C: \ php-sdk should contain sub-directories such as bin, script, and share.

6. Open the windows sdk 6.1 shell and run the following command:

PHP 5.2, 5.3 and 5.4:

Setenv/x86/xp/release

PHP 5.5 +:

Setenv/x86/2008/release

7,

Cd c: \ php-sdk \

8,

Bin \ phpsdk_setvars.bat

9,

Bin \ phpsdk_buildtree.bat php53dev

10. decompress the snapshot downloaded in step 1 to the C: \ php-sdk \ php53dev \ vc9 \ x86 folder. After decompression, the directory path is like C: \ php-sdk \ php53dev \ vc9 \ x86 \ php5.3-xyz.

11. There is a deps folder in C: \ php-sdk \ php53dev \ vc9 \ x86. Download and decompress libraries on which the compilation depends. These libraries can be obtained from http://wiki.php.net/internals/windows/libs. Make sure that the deps contains the/include and/lib directories. (Note: The author directly downloads deps-5.3-vc9-x86.7zfrom http://windows.php.net/downloads/php-sdk/, which can be successfully compiled)

12. Continue running in windows-sdk-shell

Cd C: \ php-sdk \ php53dev \ vc9 \ x86 \ php5.3-xyz

13,

Buildconf

14. View compilation options

Configure -- help

15. Enter the build command as needed:

Configure -- disable-all -- enable-cli

(Note: Some extensions require lib, header files, and other programs. For details, see libs. Download the desired version and decompress it to the deps folder c: \ php-sdk \ php53 \ vc9 \ x86 \ deps)

16,

Nmake

17. If you need to compress the compiled PHP file, continue to execute:

Nmake snap

18. The compiled PHP is located in the C: \ php-sdk \ php53dev \ vc9 \ x86 \ php5.3-SNAPSHOTTIME \ Release_TS directory.

Modify and recompile

1. Clear the last compilation result.

Nmake clean

2. If you need to re-configure

Buildconf -- force

3. Enter the new configure configuration.

Configure -- disable-all -- enable-cli -- enable-$ remains

4. Compile

Nmake

 

If you only compile the most streamlined PHP (only enable-cli), after the compilation is successful, you can observe which EXT and SAPI are compiled:

In addition to standard (standard extension), this php version only contains date, ereg, pcre, reflection, and SPL extensions. Their source code can be found in php-src/ext.

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

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.