|
 |
This install guide will help you manually install and configure PHP with
a web server on Microsoft Windows. To get started you'll need to download
the zip binary distribution from the downloads page at
/downloads.php.
Although there are many all-in-one installation kits, and we also
distribute a PHP installer for Microsoft Windows, we recommend you take
the time to setup PHP yourself as this will provide you with a better
understanding of the system, and enables you to install PHP extensions
easily when needed.
Upgrading from a previous PHP version:
Previous editions of the manual suggest moving various ini and
DLL files into your SYSTEM (i.e.
C:\WINDOWS) folder and while this
simplifies the installation procedure it makes upgrading difficult. We
advise you remove all of these files (like php.ini and PHP related
DLLs from the Windows SYSTEM folder) before moving on with a new
PHP installation. Be sure to backup these files as you might break the
entire system. The old php.ini might be useful in setting up the new
PHP as well. And as you'll soon learn, the preferred method for
installing PHP is to keep all PHP related files in one directory and
have this directory available to your systems PATH.
MDAC requirements:
If you use Microsoft Windows 98/NT4 download the
latest version of the Microsoft Data Access Components (MDAC) for your
platform. MDAC is available at http://msdn.microsoft.com/data/.
This requirement exists because ODBC is
built into the distributed Windows binaries.
The following steps should be completed on all installations before any
server specific instructions are performed:
Extract the distribution file into a directory of your choice. If you
are installing PHP 4, extract to C:\, as the zip file expands to a
foldername like php-4.3.7-Win32. If you are
installing PHP 5, extract to C:\php as the zip file doesn't expand as in
PHP 4. You may choose a different location but do not have spaces in the
path (like C:\Program Files\PHP)
as some web servers will crash if you do.
The directory structure extracted from the zip is different for PHP
versions 4 and 5 and look like as follows:
Пример 6-1. PHP 4 package structure c:\php
|
+--cli
| |
| |-php.exe -- CLI executable - ONLY for commandline scripting
|
+--dlls -- support DLLs required by some extensions
| |
| |-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 (server module support) DLLs
| |
| |-php4apache.dll
| |
| |-php4apache2.dll
| |
| |-..
|
+--PEAR -- initial copy of PEAR
|
|
|-go-pear.bat -- PEAR setup script
|
|-..
|
|-php.exe -- CGI executable
|
|-..
|
|-php.ini-dist -- default php.ini settings
|
|-php.ini-recommended -- recommended php.ini settings
|
|-php4ts.dll -- core PHP DLL
|
|-... |
|
Or:
Пример 6-2. PHP 5 package structure c:\php
|
+--dev
| |
| |-php5ts.lib
|
+--ext -- extension DLLs for PHP
| |
| |-php_bz2.dll
| |
| |-php_cpdf.dll
| |
| |-..
|
+--extras
| |
| +--mibs -- support files for SNMP
| |
| +--openssl -- support files for Openssl
| |
| +--pdf-related -- support files for PDF
| |
| |-mime.magic
|
+--pear -- initial copy of PEAR
|
|
|-go-pear.bat -- PEAR setup script
|
|-fdftk.dll
|
|-..
|
|-php-cgi.exe -- CGI executable
|
|-php-win.exe -- executes scripts without an opened command prompt
|
|-php.exe -- CLI executable - ONLY for command line scripting
|
|-..
|
|-php.ini-dist -- default php.ini settings
|
|-php.ini-recommended -- recommended php.ini settings
|
|-php5activescript.dll
|
|-php5apache.dll
|
|-php5apache2.dll
|
|-..
|
|-php5ts.dll -- core PHP DLL
|
|-... |
|
Notice the differences and similarities. Both PHP 4 and PHP 5 have a
CGI executable, a CLI executable,
and server modules, but they are located in different folders and/or have
different names. While PHP 4 packages have the server modules in the
sapi folder, PHP 5
distributions have no such directory and instead they're in the PHP
folder root. The supporting DLLs for the PHP 5 extensions are also not
in a seperate directory.
Замечание:
In PHP 4, you should move all files located in the dll and sapi folders to the main folder (e.g.
C:\php).
Here is a list of server modules shipped with PHP 4 and PHP 5:
sapi/php4activescript.dll (php5activescript.dll)
- ActiveScript
engine, allowing you to embed PHP in your Windows
applications.
sapi/php4apache.dll (php5apache.dll) - Apache 1.3.x module.
sapi/php4apache2.dll (php5apache2.dll) - Apache 2.0.x module.
sapi/php4isapi.dll (php5isapi.dll) - ISAPI Module
for ISAPI compliant web servers like IIS 4.0/PWS 4.0 or newer.
sapi/php4nsapi.dll (php5nsapi.dll) - Sun/iPlanet/Netscape
server module.
sapi/php4pi3web.dll (no equivalent in PHP 5) - Pi3Web server module.
Server modules provide significantly better performance and additional
functionality compared to the CGI binary. The CLI version is designed to
let you use PHP for command line scripting. More information about CLI is
available in the chapter about using
PHP from the command line.
Внимание |
The SAPI modules have been significantly improved as of the 4.1 release,
however, in older systems you may encounter server errors or other
server modules failing, such as ASP.
|
The CGI and CLI binaries, and the web server modules all require the
php4ts.dll (php5ts.dll) file to
be available to them. You have to make sure that this file 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,
or in case you use a SAPI module, the web server's directory (e.g.
C:\Program Files\Apache Group\Apache2\bin).
Any directory in your Windows PATH environment
variable.
To make php4ts.dll / php5ts.dll
available you have three options: copy the file to the Windows system
directory, copy the file to the web server's directory, or add your PHP
directory, C:\php to the
PATH. For better maintenance, we advise you to follow
the last option, add C:\php to the
PATH, because it will be simpler to upgrade PHP in the
future. Read more about how to add your PHP directory to
PATH in the corresponding FAQ entry.
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 because it has changes from
php.ini-dist that will drastically affect your
setup. Some examples are
display_errors being off and
magic_quotes_gpc being
off. In addition to reading these, 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 chosen ini-file to a directory that PHP is able to find
and rename it to php.ini. PHP searches for php.ini in the locations
described in Разд. The configuration file в Гл. 9 section.
If you are running Apache 2, the simpler option is to use the PHPIniDir
directive (read the installation
on Apache 2 page), otherwise your best option is to set the
PHPRC environment variable. This process is explained
in the following FAQ entry.
Замечание:
If you're using NTFS on Windows NT, 2000, XP or 2003, make sure that the
user running the web server 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
web servers document_root. For example:
Choose the 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. For an up-to-date browscap.ini, read the
following FAQ.
PHP is now setup on your system. The next step is to choose a web
server, and enable it to run PHP. Choose a webserver from the table of
contents.
Manual Installation Steps
Jason Greene
04-May-2006 06:06
If you are running websites within an Application Pool (which is now the default for IIS6 under 2K3) you need to make sure that your PHP directory (e.g. C:\PHP) has read permissions for the user assigned to the Application Pool.
1. In the IIS snap-in, choose Application Pools
2. Right-click on DefaultAppPool (or other, if you have one defined) and choose Properties
3. Click the Identity tab
4. Make a note of the user name set as the security account for this application pool (e.g. "Network Service")
5. Browse to your PHP directory and grant that user read permissions for the entire directory.
In my case, I had to add permissions for the user "NETWORK SERVICE" to get PHP scripts to work. Otherwise I received 401/403 authorization errors when trying to load them in a remote browser.
Note also that first tried adding IUSR permissions to the PHP directory, but that had no effect.
Ben
06-Apr-2006 03:17
In the Note Titled "Windows Server 2003 (x64 bits) + IIS 6.0" in step 1 when adding your new .php extension, it will not work unless after you click on the "Home Directory" you make sure that your "Execute permissions:" are set to "Scripts Only".
By default, on my machine, the permissions were set to "None" not allowing php to run.
Also, for more security it might be wise to Add the new extension just to your default site instead of the whole Web Sites folder in IIS. This would only apply if you were hosting multiple sites and had a site you didn't want scripts to run on.
Tom
13-Feb-2006 09:54
On this page and the FAQ they point out that to reset the Windows PATH variable to include your php dir, you need to completely restart the machine.
If you can't afford to do that (installing on a live server for example), you can use the setx.exe tool from the Windows Resource Kit (google it). Like so:
c:\pathtoresourcekit> setx.exe PATH "%PATH%;c:\php" \m
Windows Server 2003 (x64 bits) + IIS 6.0
31-Jan-2006 03:16
1. Add new extension (.php)
* Expand the local computer in the left pane
* Right-click on "Web Sites" in the left pane, then click "Properties" in the menu that pops up
* Flip top the "Home Directory" tab
* Click "Configuration"
* Flip to the "Mappings" tab
* Click "Add..."
* Enter the full path to php5isapi.dll in the "Executable" textbox (Browse... to find it more easily if you need to)
* Enter ".php" in the "Extension" textbox
* Select radial button "Limit to", enter "GET,POST,HEAD"
* Click "OK" all the way out
2. Verify php5isapi.dll is allowed
You must verify that the versions of php5isapi.dll that you want to use are allowed.
2.1. In Internet Information Services (IIS) Manager, in the left-hand column, click the Web Services Extensions node and verify php5isapi.dll is allowed and all other Web Service Extensions are prohibited.
2.2. If the version of php5isapi.dll that you want to use does not appear in the list, follow the instructions to enable it and then repeat this procedure:
Go into IIS
Below all of the websites is a folder: Web Service Extensions
In blue, to the lower left, is a choice: Add A New Web Service Extension
Add PHP/PHP5ISAPI.dll
Choose To ALLOW it.
2.3 If the version of php5isapi.dll you want to use appears on the list but is not allowed, right click the version of php5isapi.dll you want to allow and click Allow.
3. Configuring IIS for 32-Bit Emulation Mode (THIS IS MOST IMPORTANT!!!!)
3.1. If you are installing IIS on x64-based editions of Windows Server 2003 or Windows Server 2003 R2, IIS must be configured to run in 32 bit emulation mode. Perform the following procedure on each front-end Web server running an x64-based edition of Windows Server 2003.
Configure Internet Information Services (IIS) for 32-bit mode
1. Click Start, and then click Run.
2. In the Open box, type cmd, and then click OK.
3. In the command prompt window, navigate to the %drive%:\Inetpub\Adminscripts folder, where %drive% is the drive in which Windows Server 2003 is installed.
4. In the Adminscripts folder, type the following command:
cscript adsutil.vbs set w3svc/AppPools/Enable32bitAppOnWin64 1
Note The value "1" for Enable32bitAppOnWin64 specifies 32-bit mode, whereas the value "0" specifies 64-bit mode.
5. Press ENTER.
6. Type iisreset and then press ENTER.
7. Close the command prompt window.
8. Re-star System.
Note The Run WWW service in IIS 5.0 isolation mode check box is only selected if you have upgraded to IIS 6.0 on Windows Server 2003 from IIS 5.0 on Windows 2000. New installations of IIS 6.0 use IIS 6.0 worker process isolation mode by default.
patatraboum at nospam dot com
26-Dec-2005 06:09
IIS + PHP
- The browser can't find your php code like localhost/dir/dir_code.php from any virtual directory (404 error)
- You are sure the code exists
You may rename it with a .html extension and check if it displays
- Process of your php code like localhost/root_code.php is ok from the root directory
It may come from the doc_root directive in php.ini whitch should be set to blank :
doc_root =
Then restart IIS to reload php.ini
some dude @ some place
04-Nov-2005 08:57
on two recent installation attempts on iis6 on win2k3 i followed the php manual and windows configuration steps exactly and php would still not run.
on the first install i had to give the USER account (not IUSR) read execute permissions to this file, c:\php\sapi\php4isapi.dll. using filemon i saw that it was being accessed and access was denied.
steps:
- right click on this file > properties > security > add > location (select the server -not domain if listed) > advanced > find now > Users (usually the last item) > click OK
- select Read & Execute > apply
also a complete computer restart was required in each install
Bill dot Rook at Gmail dot com
18-Sep-2005 10:09
doc_root = ".;c:\inetpub\wwwroot" does seem to work with virtual websites. This might be a better option then commenting out the line.
Jason
09-Sep-2005 04:54
For me atleast, the steps for installing php 5 on IIS 6 on windows 2003 seemed to get buried with the other setups. I found it difficult to quickly look through and make sure I covered every step. So I created a clean step by step tutorial with screenshots:
http://psdforums.com/article.php?a=9
atomictaco at atomic-taco dot com
10-Jul-2005 09:17
In response to phpmanual at pbb dot dds dot nl:
You are absolutly correct. I found this out while trying to install PHP4 with Apache2 on XPPro. Here are 3 general guidelines that I have found to be correct:
- Path may not have spaces. Change C:\Program Files to C:\Progra~1 If you don't understand this, go to start-->run-->command (not cmd). Type cd\ and hit enter. Then type dir. You should see all your directory names there.
- Paths should not be enclosed by quotes.
- Use forward slashes (/) and not backslashes (\)
thierry dot bo at nxextxcxoxuxrxrxixexr dot com
20-Dec-2004 04:50
With PHP 4.3.x and apache 1.3.x on windows, PHPRC is used only if php is installed as cgi. With module, no matter using setenv in httpd.conf or PHPRC as windows environment variable, it is not used.
cpz at akik-ffm dot de
19-Dec-2004 10:24
In the above, "the web server's directory" means the directory where the server executable lives, for example for the Apache installation on my XP box this is "\program files\apache group\apache2\bin" and NOT just "\program files\apache group\apache2".
But it's probably best to tell your web server where PHP's ini file is stored, for example via PHPIniDir for Apache's http.conf.
chuacheehow at gmail dot com
08-Oct-2004 05:55
My experience with IIS 5.1 is that the doc_root directive be commented in order for virtual directories to recognise PHP files (with PHP installed as CGI).
phpmanual at pbb dot dds dot nl
07-Oct-2004 06:29
Okay, I'm a total newbie to this, so my findings may be wrong, but this is what I found out.
The manual says "do not have spaces in the path (like C:\Program Files\PHP) as some web servers will crash if you do". Indeed, when using this with PHP5 on WinXP, I got the error message "The specified module could not be found."
However, the problem seems not to lie in the SPACE in the pathname, but in the QUOTES that Windows adds when a space is in the pathname! This is what I found:
"C:\Program Files\php5\php5isapi.dll" -- doesn't work
C:\php5\php5isapi.dll -- works
"C:\php5\php5isapi.dll" -- doesn't work
C:\Progra~1\php5\php5isapi.dll -- works
"C:\Progra~1\php5\php5isapi.dll" -- doesn't work
C:\Program Files\php5\php5isapi.dll -- doesn't work, because it's not accepted by Internet Information Services
I don't know if this all is a problem with Internet Information Services or with PHP, but it would be nice if it was more documented in the PHP manual.
php dot user dot com
29-Aug-2004 01:43
After having the same problem as specifed below with "No input file specified". I changed the doc_root as mentioned.
This is fine if all php scripts are going to be run from the c:\inetpub\wwwroot directory. To enable it for multiple websites where the root directories are all different simply leave the doc_root attribute in the php.ini file blank.
This is for the isapi version not cgi implementation. It also means you don't have to set IUSR or IWAM access to the PHP root directory.
| |