To compile PHP from source code under Windows

Source: Internet
Author: User
Tags anonymous exit iis variables variable win32 zend microsoft iis
window| Compiler | Source code building from source
Build from source code

Before getting started, it is worthwhile answering the question: "Why are building on Windows so hard?" Two reasons come to

Mind

Before we start, let's answer a question: "Why is it so hard to compile PHP under Windows?" ", the 2 reasons for attention are:

Windows does not (yet) enjoy a large community of developers The who are willing to freely share source. As a direct

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

is available has been made possible by the porting of necessary to utilities from Unix. Dont to surprised if some of this

Heritage shows through.

Windows is not a large group of developers willing to share their code freely. The underlying investments that directly lead to supporting these developments are not established, and UNIX may have been established.

Pretty much 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.

Most of the good things below are "set and forget". So please follow these steps as closely as possible.

Preparations
Before you are started, you are have a lot to download ....

Get ready:
Before you start, you need to download a lot of things!!


For starters, get the Cygwin toolkit from the closest Cygnus mirror site. What you are are looking is Cygwin.exe file. This

Would provide you most of the popular GNU utilities used by the build process.
Http://sources.redhat.com/cygwin/download.html
Start by getting the Cygwin Toolbox from the nearest Cygnus mirror site. You're looking for a cygwin.exe file. He offers the most popular GNU tools for the compilation process:


Download the rest of the "build tools" you'll need from the PHP site at Http://www.php.net/extra/win32build.zip.

Download other tools needed for compiling from PHP site:

Get the "source code for" 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.

Get the source code used by PHP for DNS name resolution. Replace the Resolv.lib file inside the Win32build.zip

If you dont already have a unzip utility, you are need one. A free version are available from Infozip.

If you do not have a decompression tool, you need to download one. Infozip has a FREE!!

Finally, you are are going to need the source to PHP 4 itself. You can get the latest development version using anonymous CVS. If

You have a snapshot or a source tarball, you don't only'll have to Untar and ungzip it, but your'll have to convert the BA Re

Linefeeds to Crlfs in the *.DSP and *.dsw files before Microsoft Visual C + + would have anything to does with them.

Finally, you need the PHP source code itself. You can use anonymous CVS to get the latest development version. If you get a snapshot or a source code tarball, you

Not only do you need to expand it, but before Microsoft Visual C + + can handle everything, you need to convert the empty newline character in the *.DSP and *.dws files to the carriage return line symbol



Note:place the Zend and TSRM directories inside the PHP4 directory for the projects of found to is during the build

Process.

Note: Place the Zend and tstm directories inside the PHP4 directory so that the project can be found during construction

Putting it all together

Put ' em together.

Follow the instructions for installing the unzip utility of your.

Follow the steps below to install the expansion system you selected

Execute Cygwin.exe and follow the installation instructions. If you are 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 a environment variable can done

By placing a line in your Autoexec.bat. On Windows NT, Computer => control Panel => System and select the

Environment tab.

Run the Cygwin.exe and follow the installation steps. If you choose to install to a path that is not C:cygnus, you must set up the program by setting the Cygwin environment variable notification. In

Under Windows 95/98, setting environment variables can be done by adding a line to the Autoexec.bat! In Window NT, open My Computer => system and select the mirror variable

Sign.


Warning
Make a temporary directory for Cygwin to use, otherwise many commands (particularly bison) would fail. On Windows 95/98, mkdir

C:tmp. For Windows NT, mkdir%systemdrive%tmp.

Warning:
Create a temporary directory for use by Cygwin. Otherwise many commands (especially bison) will fail. Under Windows 95/98, create a directory mkdir c:tmp, in Windows NT

Under MkDir%systemdrive%tmp.


Make a directory and unzip Win32build.zip into it.

Create a directory, expand Win32build.zip into the inside

Launch Microsoft Visual C + +, and from the menu select Tools => Options. In the dialog, select the Directories tab.

Sequentially 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 the list and begin

typing). Typical entries would look like this:

Run Microsoft Visual C + + and choose Tools => option from the menu. In the dialog box, select the Directories (Path) tab. Move down to executables (can hold

Line), Includes (including file), and library (library file) file, confirm Cygwinbin,win32buildinclude, and win32buildlib in each list respectively. (

To add an entry, first the blank line at the end of the list, and then type. The typical results are as follows:

C:cygnusbin

C:php-win32buildinclude

C:php-win32buildlib

Press OK, and exit out of Visual C + +.

Press the OK key. Exit 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:

Create another directory, expand the Blindlib_w32.zip to the inside. Determine if you want to debug symbols. Establish the appropriate configuration.


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.

For GUI users, run VC + +, select File => open Workspace, and then select Bindlib. Then select Build=>set Active Configuration and select the desired

Configuration. Finally choose Build => Rebuild all.

For command line users, make sure so you either have the C + + environment variables registered, or have run Vcvars.bat, a nd

Then execute one of the following:

For command line users, verify that you have registered the C + + environment variable or have already run Vcvars.bat. Then run any of the following

Msdev bindlib.dsp/make "Bindlib-win32 Debug"

Msdev bindlib.dsp/make "Bindlib-win32 release"

At I, 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" same name found in there.

At this point, you get a usable resolv.lib under your Debug or release subdirectory. Copy this file into your Win32buildlib directory, covering the same

Name of the file.

Compiling

Compile

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

It's best to start a standalone/cgi version.


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.

For GUI users, run VC + +, select the File => Open Workspace Select Php4ts, and then select Build => Set Active Configuration to select the desired configuration.

Finally choose Build => Rebuild all.

For command line users, make sure so you either have the C + + environment variables registered, or have run Vcvars.bat, a nd

Then execute one of the following:

For command line users, verify that you have registered the C + + environment variable or have already run Vcvars.bat. Then run any of the following

Msdev php4ts.dsp/make "Php4ts-win32 debug_ts"

Msdev php4ts.dsp/make "Php4ts-win32 release_ts"

At I, you should have a usable php.exe in either your debug_ts or release_ts.
At this point, you can get the available php.exe under your debug_ts or Release_ts subdirectory.

Repeat the above steps with PHP4ISAPI.DSP (which can is found in Sapiisapi) the code necessary

Integrating PHP with Microsoft IIS.

Repeat the above steps for PHPISAPI.DSP (found in Sapiisapi). Establishes an ISAPI program for Microsoft IIS.

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.