本节内容适用于 Windows 98/Me 以及 Windows NT/2000/XP/2003。PHP
不能在 16 位平台例如 Windows 3.1 下运行。有时把支持 PHP 的 Windows 平台称为
Win32。自 PHP 4.3.0 开始不再支持 Windows 95。
有两种方法在 Windows 下安装 PHP：手工安装或者使用安装程序安装。
如果有 Microsoft Visual Studio，也可以编译 PHP 的源程序。
一旦在 Windows 系统下安装好 PHP 之后，可能需要加载各种扩展库以实现更多的功能。
PHP 的 Windows 安装程序可以在
IIS、PWS 和 Xitami 安装
CGI 版本的 PHP，并配置好 web 服务器。该安装程序不包含任何外部的
PHP 扩展（PHP_*.dll）。如果需要，可以在 Windows ZIP 包和
虽然 Windows 安装程序是让 PHP
PHP 扩展。使用安装程序安装 PHP 不是最好的方式。
安装向导会收集足够的信息来设置 php.ini 文件，并配置好 web 浏览器以使用 PHP。PHP
请注意，这种安装方式安装的 PHP 不是安全的。如果需要一个安全的 PHP
IIS6 AND PHP5 on w2k3
1.download php and unzip to c:\php
- also create c:\php\sessions
2.add c:\php to you path
-right click mycomputer,properties,advance,env variables
2.On IIS Manager add web service extension
-name: php isapi
-req files: c:\php\php5isapi.dll
3.Now let iis know what to do with .php
-On iis Manager,right click Web Sites, properties, home directory tab, configuration button, add button
limit to: GET,POST,HEAD
4. rename php.ini-recommended to php.ini
you can copy php.ini to c:windows or modify the registry to look for php.ini in c:\php
to use the registry create a php.reg file with the following inside. after this just double click. do not put the lines.
Windows Registry Editor Version 5.00
5. modify php.ini with
short_open_tag = On
extension_dir = "c:\php\ext"
cgi.force_redirect = 0
6. the web sites are going to be using the default pool. this runs under network service. go to c:\php and give the network service read& execute, list folder content,read
-go to c:\php\sessions and add write and modify access network service
max dot floden at tjitjing dot com
This is a great instruction for installing php 5 on a windows 2003/iis 6 server. There are many other instructions out there (several listed here) but this is by far the easiest to follow and the only one I found that actually works with php 5 and iis 6.
(Updated with new/corrected url to original note by John Kerner on 20-Apr-2005 03:23
Had to put a space after blog in url to be able to post note - it does wrap fine due to all dashes but refuses to be submitted)
winterspan - AT - g m a i l . /C/O/M
READ HERE If installing PHP 5.x on Windows Server 2003 / IIS 6.x ...
It was extremely frustrating getting this to work, so hopefully my struggle will allow others to do this the *easy* way.
BEFORE installing PHP 5 from a web tutorial (a good one found here: http://www.peterguy.com/php/install_IIS6.html)
You need to READ THESE TIPS:
#Necessary Permissions For WinServer 2003 / IIS6.0#
These are the permission settings I found to work well with good security:
NTFS permissions (right-click file or folder, select preferences, go to security tab)
1) PHP Install folder -> You need to give NT account: 'Network Service' read/execute permissions on the 'php' install folder (e.g., C:\\PHP). If you have a TMP or SESSION folder within the main PHP folder, you need to give account 'Network Service' read/execute AND write access on those folders. *(You DO NOT need to give the anonymous internet user account: 'IUSR_[name]' ANY permissions on the PHP INSTALL files themselves. )*
2) You DO need to give account: 'IUSR_name' Read/execute
permissions on the actual WWW root folder and web .php files (if you want to apply to all sites) or each websites WWW root and .php files if running multiple sites.
3) Within the IIS 6.0 console itself, in the website's preferences (right click on ind. site or 'websites' node to apply to all sites -> select preferences) on the
'Directory Security' tab -> click edit, and if you wish to allow anonymous access to your site, check the anonymous access box and be sure to enter account: 'IUSR_name'.
4) *MOST IMPORTANT*
As mentioned by a few others, install php and configure the php.ini WITH NO EXTENSIONS AT FIRST. The reason being if one of the extensions fail, the error dialog will pop up OUTSIDE of a terminal services window (remote desktop). So you will NOT BE ABLE to click on the error, and the websites php file you are trying to load in your browser will hang indefinately (after having this happen for 12 hours I almost went insane trying to figure out the problem) LOL.
Then when you have successfully loaded a test php page in the browser, go back to the php.ini file and add extensions in one at a time.
If YOU have any tips I haven't included, email me. Again,
I am not a professional, still a student in learning. :)
Now that you have read that, go back to the link I placed near the top, and follow his tutorial for general installation/setup.
If the path to your PHP directory has spaces (e.g. "C:\\Program Files\\PHP") and IIS gives a 500+ error or responds with "The specified module could not be found." when you try to run a PHP script, try changing the ISAPI DLL's path in IIS (in the "Home Directory" tab, under "Configuration...") to the 8.3-equivalent path.
That is, use C:\\PROGRA~1\\PHP\\php5isapi.dll instead of "C:\\Program Files\\PHP\\php5isapi.dll".
SmugWimp at smugwimp dot com
If you make changes to your PHP.ini file, consider the following.
(I'm running IIS5 on W2K server. I don't know about 2K3)
PHP will not "take" the changes until the webserver is restarted, and that doesn't mean through the MMC. Usually folks just reboot. But you can also use the following commands, for a much faster "turnaround". At a command line prompt, type:
and that will stop the webserver service. Then type:
net start w3svc
and that will start the webserver service again. MUCH faster than a reboot, and you can check your changes faster as a result with the old:
in your page somewhere.
I wish I could remember where I read this tip; it isn't anything I came up with...
ratkinson at tbs-ltd dot co dot uk
When installing onto the Windows IIS platform, ensure you add the PHPRC Server Variable to point to your PHP.INI file.
Also, add '.INI' to the FILEEXT Server Variable. Failure to add these could stop the PHP engine being able to find your PHP.INI file, and none of your modifications will be read.
If you get problems with ISS 6 and PHP try this:
I've tried to install in a different folder than c:\php but when you add the application extension mapping the ISS does not accept a path with spaces (like c:\program files\php).
Thought someone would save some time and headaches by using this post.
Our tech department is migrating to Windows 2003 Server and they have some complex security implementations between our Web Servers and our Application (COM) servers.
If you have this type of scenario and are receiving the "Warning (null)(): Unable to lookup.... Access is denied." error, it is because the "Identity" in the Web Server's application pool does not have sufficient permissions to connect to the Application (COM) Server.
To fix this:
- create a new Application Pool
- right click the new pool and select "properties"
- click on the "Identity" tab
- change the permissions from "Network Service" to a user on the Web Server who has access to call the Application (COM) server.
- right click the application pool
- click "start"
- right click your web site
- click on the "Home Directory" tab
- change the application pool to the new application pool you've just created.
- restart IIS
Hopefully this will save someone some time and headaches.
I've installed Apache + PHP on a Windows machine of which I'm not an administrator.
I found out it was necessary to change the permissions of the httpd.conf file on C:\Program Files\Apache Group\Apache\conf in order to have everything working. Since I'm also using cygwin this was simply done with: >chmod 755 httpd.conf.
lukasz at szostak dot biz
You can have multiple versions of PHP running on the same Apache server. I have seen many different solutions pointing at achieving this, but most of them required installing additional instances of Apache, redirecting ports/hosts, etc., which was not satisfying for me.
Finally, I have come up with the simplest solution I've seen so far, limited to reconfiguring Apache's httpd.conf.
My goal is to have PHP5 as the default scripting language for .php files in my DocumentRoot (which is in my case d:/htdocs), and PHP4 for specified DocumentRoot subdirectories.
Here it is (Apache's httpd.conf contents):
# replace with your PHP4 directory
ScriptAlias /php4/ "c:/usr/php4/"
# replace with your PHP5 directory
ScriptAlias /php5/ "c:/usr/php5/"
AddType application/x-httpd-php .php
Action application/x-httpd-php "/php5/php-cgi.exe"
# populate this for every directory with PHP4 code
Action application/x-httpd-php "/php4/php.exe"
# directory where your PHP4 php.ini file is located at
SetEnv PHPRC "c:/usr/php4"
# remember to put this section below the above
# directory where your PHP5 php.ini file is located at
SetEnv PHPRC "c:/usr/php5"
This solution is not limited to having only two parallel versions of PHP. You can play with httpd.conf contents to have as many PHP versions configured as you want.
You can also use multiple php.ini configuration files for the same PHP version (but for different DocumentRoot subfolders), which might be useful in some cases.
Remember to put your php.ini files in directories specified in lines "SetEnv PHPRC...", and make sure that there's no php.ini files in other directories (such as c:\windows in Windows).
And finally, as you can see, I run PHP in CGI mode. This has its advantages and limitations. If you have to run PHP as Apache module, then... sorry - you have to use other solution (the best advice as always is: Google it!).
Hope this helps someone.
phil at pelanne dot com
For those of you trying to install PHP 4 and PHP 5 concurrently on a windows 2003 box, there is just one rule you need to adhere to in order to make it work:
- Don't have either of them in c:\php\.
- Don't have a php.ini in your system32 directory.
Put PHP 4 into a directory called c:\php4\. Put its php.ini in there, and make sure all the paths reflect the c:\php4 directory.
Likewise, put PHP 5 into a directory called c:\php5\. Put its php.ini in there, and make sure all the paths reflect the c:\php5 directory.
Add them as allowed script mappings in your iis extensions area, and have fun!
Note to windows server 2003 users
If you install php5 ISAPI on windows server 2003 / IIS and keep getting a 404 when you try to view a php script don`t just activate "all unknown ISAPI extensions" but also activate "All Unknown CGI Extensions".
I've installed php 5.0.5 with the ISAPI module, as the isapi dll file (php5isapi.dll) resides in the php root directory, I didn't have trouble in my installation (In php4 this dll file is in sapi directory and it should be moved to php root directory).
I changed some of my settings in php.ini file and restart IIS Web site,but my changes weren't applied.
Then I go to Control Panel>Administrative Tools>Services and restart the IIS Admin Service.
Everything worked like a charm...
thedeadraptor2000 at yahoo dot com
Note regarding PHP4 Installation on IIS5 + Win2K
Tip: Don't install PHP4 on Directories with spaces in between.
I've had problems Installing PHP 4.0.0 on IIS5, Win2k's default web server, spanish version (I live in Colombia). I've had HTTP 500 Errors and I followed all instructions step by step, but nothing seemed to work.
I solved the problem eventually, and I think it had something to do with the fact that I have installed PHP4 manually and placed it in the directory "C:\Archivos de programa\php-4.4.0-Win32" ('Archivos de programa' stands for 'Program Files'), a directory with spaces in between.
When I added the application mappings for "C:\Archivos de programa\php-4.4.0-Win32/sapi/php4isapi.php", An error would ocurr and a message along with it: "Escriba una ruta de acceso valida", as in "Write a valid access rute", as in "I can't find the file".
I thought i had it when I encapsulated it with Doublequotes ("), but that didn't work either.
As a final long shot, I copied the php4isapi.dll to the windows/system32 directory and 'WALA!' It worked.
I'm not sure, but i suspect that it had to do with spaces in between directory names, so avoid those, or copy the isapi module to another directory.
Hope this helps someone!
wappa at hotmail dotandthekangaroo com
Don't forget if you are getting ACL exceptions to reading the test php page you have created you MUST share the PHP directory or the resources PHP uses to "everyone" but remember use restricted access for security.
jp at iticonsulting dot nl
If you get 404 page not found on Windows/IIS5, have a look at C:\SYSTEM32\INETSRV\URLSCAN
There is a .ini file there that prevents some files from being served by IIS, even if they exist, instead IIS will give a 404. The urlscan logfile (same place) should give you some insight into what parameter is preventing a page from loading, if any.
In order to run php scripts with php.exe CGI instead of php4isapi.dll under IIS, following steps can be followed.
i) Add a web service extension for PHP using IIS manager. Choose a web service extension name like 'PHP' and add your php.exe path in the 'file location' while adding the required file e.g. 'C:\php\php.exe' in the Add extension dialog box. Don't forget to 'Allow' the extension file.
ii) Open php.ini file located at %systemroot%. Set the following variables to the shown values.
cgi.force_redirect = 0
cgi.redirect_status_env = ENV_VAR_NAME
iii) In your websites, add Application Mapping for '.php' and set the executable path to your php.exe file path.
You can test whether PHP is running or not and other PHP settings using the following simple PHP script.
ferozzahid [_at_] usa [_dot_] [_com_]
steve at lonetree dott com
Hello all. Well, I'm an experienced iis admin, but I tell you, I had a devil of a time getting it to run correctly. My issue was that I was trying to do everything via term services...use this link
to view some seriously interesting notes on this. This guy's info was SPOT ON and worked perfectly for me. Don't forget to give Network Service group read/execute access to your web content...
donald at netriver dot net
On the Windows 2003 & IIS6 platform, you can run different websites on different versions & copies of PHP. This is useful in at least two cases:
1. You want one website on your box to have register_globals on, but since you're running IIS, you cannot specify that in an .htaccess file. And you definately don't want register_globals on for the rest of the websites.
2. You want to run different versions of PHP for different websites, or even just different extensions. Say you wanted one site to use 4.0.5 and a different site to use 4.1.11.
Its simple, just:
1. Move your php.ini file from your c:\windows\ directory directly to your php directory (by default that would be c:\php\)
2. Make sure you don't have a php.ini file in any other location that would supercede the c:\php\php.ini file. Using phpinfo(); is useful here.
3. Have your alternate version of php (either a different version or a different php.ini) have its own install directory, like c:\php4RG\ or c:\php405\.
4. In the Home Directory Configuration for your website, specify the .php extension to use a different script, pointing it at the alternate directory.
gary at garyslittlecompany dot com
php compiled with eapi on windows. Spend hours trying to find something that would work for the
"Loaded DSO /..../php4apache.dll uses plain 1.3 API, this module might
crash under EAPI! (please recompile it with -DEAPI)".
Finally compiled it.
If you would like the binaries or instructions on how I did it email me.
doyouunderstand at gmail dot com
For those having trouble installing PHP 5+ ISAPI for IIS 6 (on Windows 2003 server), who have tried everything on this site and all over the net, with no success (like I did) - try the following before throwing your server out of a 3rd story window.
It was the only thing that worked out of all the many solutions I tried.
Probably some other solutions would've worked as well, but in my frusterated state of mind, this explanation was the clearest.
My problem was that in addition to adding the the Web service extension, I was not adding the ISAPI extensions for the websites in IIS Manager manaully. ALSO, remember to reboot after the changes on the site listed above. It's the only thing he forgot to mention, and depending on your setup, you may need to reboot to register the dll moves and changes made. (IIS restart will not re-register dlls).
Just a note following on from Luis D regarding adding the pgp4ts.dll as a Web Server Extension.
I just used the latest php-4.3.10-installer.exe from php.net and had the problems where .php files could not be found.
In order to get them to work I added and allowed the php.exe as a Web Service Extension and not the php4tx.dll.
claudio_jvt at hotmail dot com
One very helpfull note to Win2003 iis6 users:
If you'd like to use isapi in the web service extensions and you're in a development server (or even if your php.ini config file changes frequently), here's what you can do:
Php.ini runtime changes:
Create a new application pool in iis:
iis->select server->application pools->new application pool
Use default settings;
go to the application pool you've created, properties->
check the "Recycle worker process" option, and give it a small value (10 is nice :) ).
Now go to your site (or virtual directory site)-> properties->
change the application pool to the newly configured appPool.
At this moment, is good to make a iss restart (note this is the only resart needed).
Your site is now semi-runtime changed :)
You can try it with the usal php info() test. Change something in the php.ini and check the number of requests it takes to use the new configuration.
The downside of this approach (wich is still better than to use php-cgi.exe): the process is recycled, so all the configuration in php.ini is read every N requests - with php-cgi.exe, this would happen for every request, so.. is a good solution.
Again, be carefull when using this in a production environment, since the load can increase (not sure how much, but it will certainly increase).
And keep in the new appPool JUST the php sites that require runtime changes in php.ini !
You've helped me, so I help you ;)
chris at move dash media dot com
Note to windows users, if you are trying to install php5 ISAPI on windows server 2003 / IIS and getting a 404 when you try to view a simple php script, even though everything else seems to be right... click into "web service extensions" from IIS and either add a new web service extension, or click onto "all unknown ISAPI extensions" and click allow.
ntadmin at aplus dot net
When configuring application pools with configurable
accounts instead of NETWORK SERVICE or LOCAL SYSTEM
remember to add the user to the correct security contexts found here:
Note: Watch for wordwrap
Otherwise you will recieve 403 errors.
This fixes the "The directory name is invalid" error.
In IIS 5.1 on Windows XP Pro, Go into the Internet Information Services, and into the properties of the virtual directory where the problem occurs. On The 'Virtual Directory' tab, click on the 'Configuration...' button. Select the '.php' extension, and press 'Edit'. On the bottom, Check the 'Check that file exists' checkbox.
This is just to clarify on a posting on this page that states the nescesity of allowing all unknown cgi Extensions in Windows 2003 IIS 6. Although this will work and it should be consider as a quick option for an itranet solution with no web access at all.
This poses a very serious security problem and its not the best course of action, in my opinion. The proper way of making this work will be to actually enable the extension that you want to execute. After verifying that the .php extension is present, simply go to "Web Service extensions" in the IIS Manager and click on "Add a new web service extension";
Once the "new web service extension" opens:
1- Add the "extension name" field, please enter "PHP" (or what ever you wanna call it) Other more conservative admins will say call it what it is and always input ".php". Its up to you!
2-Click on the "add" button and browse to the php4ts.dll file on your c:\PHP (default) and then click open --> OK and set the checkmark under "set extension status to allowed" click OK and thats it!!!
If you missed the checkmark moment cause you are just so impatient, like me, then simply select the extension on the web service extensions windows and click ALLOW.
This is a very simple process and it will work everytime.
I hope this helps, as I have found several things in this forums that are incredibly helpfull!!
PS: For the non programmer, it is a good practice to install mysql and a free php forum like bb2 to test how well your php IIS and mysql is working.
ferchland at computer-kontor dot de
If need a php4apache.dll compiled with EAPI _and_ you run Apache with mod_ssl, use the Apache from
This is already a binary for win32, but the *.lib and headers are included.
ungdi at hotmail dot com
Under a Windows 2003 and IIS 6.x installation of PHP, it is interesting to note that by default in most cases, the "DefaultAppPool" for the "Default Web Site" is running under the security context of "Network Service" which maybe too restrictive. This results in a 403: Forbidden error every time you try to access a PHP page.
You have several options to remedy the problem:
an obvious one is to make it run as the "Local System", but that may be too much power for some administrators' tastes.
The other option is at the IIS Manager,
go to the computer's "Application Pools" folder,
and go to the properties dialog box of the "DefaultAppPool",
and then to the "Identity" tab, and select the "Configurable" identity of "IWAM_[COMPUTER_NAME]" as the security context. This will make the application pool run the way it did in the previous versions.
This solved the repeated problems of the 403 errors. However, do not forget to give permission to "IUSR_[COMPUTER_NAME]" and "IWAM_[COMPUTER_NAME]" appropriate directory permissions for your web directories as stated above.
spf at users dot sf dot net
To allow acWEB.sf.net win32-webserver and Eserv 2.98 (www.eserv.ru) web-server run PHP 4.2.2 without problems with FORCE_REDIRECT you should set "cgi.force_redirect = Off" in php.ini in windows directory.
adam dot swick at pantellos dot com
IIS 5: If you change the application mappings for PHP (for example, from CGI to ISAPI module), reboot after the change is made. The PHP Application Mapping change may cause a conflict if ISAPI applications are cached.
mike at schild dot com
It's a hard way to get work php on win98/PWS... but with this comment-page I found it out how it works:<br>
- error 403: give read/write rights to the directory. You can do this by clicking the right mouse key on the directory in the explorer.<br>
- html file in a dos box: 1) clean the "doc_root" line in the php.ini file. 2) start personal web-manager / go to 'advanced' / make for your web-default-directory a virtual directory with all possible rights.<br>
On my system it works now!