This section applies to Windows 98/Me and Windows NT/2000/XP_ PHP
will not work on 16 bit platforms such as Windows 3_1 and sometimes
we refer to the supported Windows platforms as Win32_ Windows 95
is no longer supported as of PHP 4_3_0_
There are two main ways to install PHP for Windows: either
manually
or by using the InstallShield
installer_
If you have Microsoft Visual Studio, you can also
build
PHP from the original source code_
Once you have PHP installed on your Windows system, you may also
want to load various extensions
for added functionality_
Windows InstallShield
The Windows PHP installer is available from the downloads page at
http://www_php_net/downloads_php_ This
installs the CGI version of PHP
and, for IIS, PWS, and Xitami, configures the web server as well_
Nota:
While the InstallShield installer is an easy way to make
PHP work, it is restricted in many aspects, as
automatic setup of extensions for example is not supported_ The whole set
of supported extensions is only available by downloading the zip binary
distribution_
Install your selected HTTP server on your system and
make sure that it works_
Run the executable installer and follow the instructions provided by the
installation wizard_ Two types of installation are supported _ standard,
which provides sensible defaults for all the settings it can, and advanced,
which asks questions as it goes along_
The installation wizard gathers enough information to set up the php_ini
file and configure the web server to use PHP_ For IIS and also PWS on NT
Workstation, a list of all the nodes on the server with script map settings
is displayed, and you can choose those nodes to which you wish to add the
PHP script mappings_
Once the installation has completed the installer will inform you if you
need to restart your system, restart the server, or just start using PHP_
Aviso
Be aware, that this setup of PHP is not secure_ If you would like to have
a secure PHP setup, you'd better go on the manual way, and set every
option carefully_ This automatically working setup gives you an instantly
working PHP installation, but it is not meant to be used on online servers_
PHP 4 for Windows comes in three flavours _ a CGI executable (php_exe), a
CLI executable (sapi/php_exe) and some other SAPI modules:
php4apache_dll _ Apache 1_3_x module
php4apache2_dll _ Apache 2_0_x module
php4isapi_dll _ ISAPI Module for ISAPI compliant
webservers like IIS 4_0/PWS 4_0 or newer_
php4nsapi_dll _ Netscape/iPlanet module
The latter form is new to PHP 4, and provides significantly improved
performance and some new functionality_ The CLI version is designed to use
PHP for command line scripting_ More information about CLI is available in
the chapter about
using PHP from the command line
Aviso
The SAPI modules have been significantly improved in the 4_1 release,
however, you may find that you encounter possible server errors or
other server modules such as ASP failing, in older systems_
DCOM and MDAC requirements:
If you choose one of the SAPI modules and use
Windows 95, be sure to download and install the DCOM
update from the Microsoft DCOM pages_
If you use Microsoft Windows 9x/NT4 download the
latest version of the Microsoft Data Access Components (MDAC) for your
platform_ MDAC is available at http://www_microsoft_com/data/_
The following steps should be performed on all installations before any
server specific instructions_
Extract the distribution file to a directory of your choice,
c:\ is a good start_ The zip package expands to a
foldername like php_4_3_1_Win32 which is assumed to
be renamed to php_ For the sake of convinience and
to be version independant the following steps assume your extracted
version of PHP lives in c:\php_ You might choose
any other location but you probably do not want to use a path in which
spaces are included (for example:
c:\program files\php is not a good idea)_ Some web
servers will crash if you do_ The struture of your directory you
extracted the zip file will look like:
c:\php
|
+__cli
| |
| |_php_exe __ CLI executable _ ONLY for commandline scripting
|
|
+__dlls __ support dlls for extensions __> Windows system directory
| |
| |_expat_dll
| |
| |_fdftk_dll
| |
| |____
|
+__extensions __ extension dlls for PHP
| |
| |_php_bz2_dll
| |
| |_php_cpdf_dll
| |
| |___
|
+__mibs __ support files for SNMP
|
|
+__openssl __ support files for Openssl
|
|
+__pdf_related __ support files for PDF
|
|
+__sapi __ SAPI dlls
| |
| |_php4apache_dll
| |
| |_php4apache2_dll
| |
| |_php4isapi_dll
| |
| |___
|
|_install_txt
|
|___
|
|_php_exe __ CGI executable
|
|___
|
|_php_ini_dist
|
|_php_ini_recommended
|
|_php4ts_dll __ main dll __> Windows system directory
|
|____
The CGI binary _ C:/php/php_exe _, the CLI binary
_ c:\php\cli\php_exe _, and the SAPI modules
_ c:\php\sapi\*_dll _ rely on the main dll
c:\php\php4ts_dll_ You have to make sure, that this
dll can be found by your PHP installation_ The search order for this dll
is as follows:
The same directory from where php_exe is called_
In case you use a SAPI module the same directory from where your
webserver loads the dll (e_g_ php4apache_dll)_
Any directory in your Windows PATH environment variable_
The best bet is to make php4ts_dll available,
regardless which interface (CGI or SAPI module) you plan to use_ To do so,
you have to copy this dll to a directory on your Windows path_ The best
place is your Windows system directory:
c:\windows\system for Windows 9x/ME
c:\winnt\system32 for Windows NT/2000 or
c:\winnt40\system32 for NT/2000 server
c:\windows\system32 for Windows XP
If you plan to use a SAPI module from c:\php\sapi
and do not like to copy dlls to your Windows system directory, you have
the alternative choice to simply copy php4ts_dll to
the sapi folder of your extracted zip package,
c:\php\sapi_
The next step is to set up a valid configuration file for PHP, php_ini_
There are two ini files distributed in the zip file,
php_ini_dist and
php_ini_recommended_ We advise you to use
php_ini_recommended, because we optimized the
default settings in this file for performance, and security_ Read this
well documented file carefully and in addition study the
ini settings and set every
element manually yourself_ If you would like to achieve the best
security, then this is the way for you, although PHP works fine with
these default ini files_ Copy your choosen ini_file to a directory where
PHP is able to find and rename it to php_ini_ By default PHP searchs
php_ini in your Windows directory:
On Windows 9x/ME/XP copy your choosen ini file to your
%WINDIR%, which is typically
c:\windows_
On Windows NT/2000 copy your choosen ini file to your
%WINDIR% or %SYSTEMROOT%,
which is typically c:\winnt or
c:\winnt40 for NT/2000 servers_
If you're using NTFS on Windows NT, 2000 or XP, make sure that
the user running the webserver has read permissions to your
php_ini (e_g_ make it readable by Everyone)_
The following steps are optional_
Edit your new php_ini file_
If you plan to use OmniHTTPd,
do not follow the next step_ Set the
doc_root to point to your webservers
document_root_ For example:
doc_root = c:\inetpub // for IIS/PWS
doc_root = c:\apache\htdocs // for Apache
Choose which extensions you would like to load when PHP starts_ See
the section about
Windows extensions,
about how to set up one, and what is already built in_ Note that on
a new installation it is advisable to first get PHP working and tested
without any extensions before enabling them in php_ini_
On PWS and IIS, you can set the
browscap configuration setting
to point to:
c:\windows\system\inetsrv\browscap_ini on
Windows 9x/Me,
c:\winnt\system32\inetsrv\browscap_ini on
NT/2000, and
c:\windows\system32\inetsrv\browscap_ini
on XP_
Following this instructions you are done with the basic steps to setup PHP
on Windows_ The next step is to choose a webserver and enable it to run
PHP_ Installation instructions for the following webservers are available:
__ the Windows server family, Personal
Web server (PWS) 3 and 4 or newer; Internet Information Server (IIS) 3
and 4 or newer_
Before getting started, it is worthwhile answering the question:
"Why is building on Windows so hard?" Two reasons come to mind:
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 hasn't been made_ By and large,
what is available has been made possible by the porting of
necessary utilities from Unix_ Don't be surprised if some of
this heritage shows through from time to time_
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_
Requerimientos
To compile and build PHP you need a Microsoft
Development Environment_ Microsoft Visuaul C++ 6_0 is recommended_
To extract the downloaded files you need a extraction utilitiy
(e_g_: Winzip)_ If you don't already have an unzip utility, you
can get a free version from InfoZip_
__the source code for the DNS name resolver used by PHP
from
http://www_php_net/extra/bindlib_w32_zip_ This is a replacement for the
resolv_lib library included in
win32build_zip_
If you plan to compile PHP as a Apache
module you will also need the Apache
sources_
Finally, you are going to need the source to PHP 4 itself_ You can get
the latest development version using
anonymous CVS, a
snapshot or the most recent released
source tarball_
Putting it all together
After downloading the required packages you have to extract them in a
proper place_
Create a working directory where all files end up after extracting, e_g:
c:\work_
Create the directory win32build under your
working directory (c:\work) and unzip
win32build_zip into it_
Create the directory bindlib_w32 under your
working directory (c:\work) and unzip
bindlib_w32_zip into it_
Extract the downloaded PHP source code into your working directory
(c:\work)_
Following this steps your directory structure looks like this:
Create the directories c:\usr\local\lib_ Copy
bison_simple from c:\work\win32build\bin
to c:\usr\local\lib_
Nota: Cygwin users may omit the last
step_ A properly installed Cygwin environment provides the mandatory
files bison_simple and
bison_exe_
Configure MVC ++
The next 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:
You must build the resolv_lib library_
Decide whether you want to have debug symbols available
(bindlib _ Win32 Debug) or not (bindlib _ Win32 Release)_
Build the appropriate configuration:
For GUI users, launch VC++, and then select File => Open
Workspace, navigate to c:\work\bindlib_w32 and
select bindlib_dsw_ Then select Build=>Set
Active Configuration and select the desired configuration_
Finally select 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
commands:
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 c:\work\bindlib_w32\Debug or
Release subdirectories_ Copy this file into your
c:\work\win32build\lib directory over the file
by the same name found in there_
Compiling
The best way to get started is to build the CGI version_
For GUI users, launch VC++, and then select File => Open
Workspace and select c:\work\php_4_x_x\win32\php4ts_dsw
_ Then select Build=>Set Active
Configuration and select the desired configuration, either
php4ts _ Win32 Debug_TS or
php4ts _ Win32 Release_TS_ Finally select
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 commands from the c:\work\php_4_x_x\win32
directory:
At this point, you should have a usable php_exe
in either your c:\work\php_4_x_x_\Debug_TS or
Release_TS subdirectories_
It is possible to do minor customization to the build process by editing
the main/config_win32_h file_ For example you can
change the default location of php_ini, the builtin extensions, and the
default location for your extensions_
Next you may want to build the CLI version which is designed to use
PHP from the command line_
The steps are the same as for building the CGI version, except you have
to select the php4ts_cli _ Win32 Debug_TS or
php4ts_cli _ Win32 Release_TS project file_ After a
succcessfull compiling run you will find the php_exe
in either the directory Release_TS\cli\ or
Debug_TS\cli\_
Nota:
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
PEAR website_
In order to build the SAPI module (php4isapi_dll)
for integrating PHP with Microsoft IIS, set your active configuration to
php4isapi_whatever_config and build the desired dll_
Installation of Windows extensions
After installing PHP and a webserver on Windows, you will probably want to
install some extensions for added functionality_ You can choose which
extensions you would like to load when PHP starts by modifying your
php_ini_ You can also load a module dynamically in your script using
dl()_
The DLLs for PHP extensions are prefixed with 'php_' in PHP 4 (and
'php3_' in PHP 3)_ This prevents confusion between PHP extensions
and their supporting libraries_
Nota:
In PHP 4_3_1 BCMath, Calendar, COM, Ctype, FTP, MySQL, ODBC, Overload,
PCRE, Session, Tokenizer, WDDX, XML and Zlib support is
built in_ You don't need to load any additional
extensions in order to use these functions_ See your distributions
README_txt or install_txt
or this table
for a list of built in modules_
The default location PHP searches for extensions is
c:\php4\extensions_ To change this setting to reflect
your setup of PHP edit your php_ini file:
You will need to change the
extension_dir setting to
point to the directory where your extensions lives, or where you have
placed your php_*_dll files_ Please do not
forget the last backslash_ For example:
extension_dir = c:/php/extensions/
Enable the extension(s) in php_ini you want to use by uncommenting the
extension=php_*_dll lines in php_ini_ This is done
by deleting the leading ; form the extension you want to load_
Ejemplo 3_4_ Enable Bzip2 extension for PHP_Windows
// change the following line from ___
;extension=php_bz2_dll
// ___ to
extension=php_bz2_dll
Some of the extensions need extra DLLs to work_ Couple of them can be
found in the distribution package, in the
c:\php\dlls\ folder but some, for example Oracle
(php_oci8_dll) require DLLs which are not bundled
with the distribution package_ Copy the bundled DLLs from
c:\php\dlls folder to your Windows PATH, safe
places are:
c:\windows\system for Windows 9x/Me
c:\winnt\system32 for Windows NT/2000
c:\windows\system32 for Windows XP
If you have them already installed on your system, overwrite them only
if something doesn't work correctly (Before overwriting them, it is a
good idea to make a backup of them, or move them to another folder _
just in case something goes wrong)_
Nota:
If you are running a server module version of PHP
remember to restart your webserver to reflect your changes to php_ini_
The following table describes some of the extensions available and required
additional dlls_