处理 SSI 文件时出错
网站工程
 规划发展   网页美工   标记语言   网页编程   Web服务器   广告攻略   开发常识   趋势研究   网站维护   网站数据库   网页设计工具
 论坛
您现在的位置: IT文谷 >> 网站工程 >> Web服务器 >> IIS >> 文章正文
国外的一篇在IIS6上安装PHP5的教程国外的一篇在IIS6上安装PHP5的教程2006-12-18 14:44:01国外的一篇在IIS6上安装PHP5的教程2006-12-18 14:44:01国外的一篇在IIS6上安装PHP5的教程
国外的一篇在IIS6上安装PHP5的教程
国外的一篇在IIS6上安装PHP5的教程国外的一篇在IIS6上安装PHP5的教程2006-12-18 14:44:01国外的一篇在IIS6上安装PHP5的教程2006-12-18 14:44:01国外的一篇在IIS6上安装PHP5的教程
处理 SSI 文件时出错
国外的一篇在IIS6上安装PHP5的教程国外的一篇在IIS6上安装PHP5的教程2006-12-18 14:44:01国外的一篇在IIS6上安装PHP5的教程2006-12-18 14:44:01国外的一篇在IIS6上安装PHP5的教程
Last changed 10:40 PM 2/7/2005
questions/props/corrections/etc... > petera spammer-at-peterguy.com (delete a spammer to email)
flames > /dev/null ;-)

!!!!!!!!!!!! NOTICE !!!!!!!!!!!

This guide is no longer being maintained.
You will find the most up-to-date information
in a much better-looking html-formatted guide at

http://www.peterguy.com/php/install_IIS6.html

Please go there now. :-)

!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!

How to install PHP 5.x on Windows Server 2003 with IIS 6.

A detailed and hopefully helpful step-by-step guide, based on my experience.

YMMV.

The lines beginning with dashes are the steps, the stuff in between is more detail should you need it.

I'm hoping to convert this to an html-based guide that's prettier, but my time is limited.

This guide does not cover initial setup of IIS, or configuration of a Windows 2003 server in general.

This guide is divided into 3 main steps:
1. install PHP (the easiest step, like having a baby is to raising a child)
2. Configure PHP (lots of php.ini editing)
3. Configure IIS (lots of pointing and clicking in IIS Manager)


So, let's get into it...


*************************
1. Install PHP
*************************


1.1 Unzip latest version of PHP to C:\PHP (I used 5.0.2)

Download the latest zipped distribution of PHP from php.net, not the Windows installer.
You can pick any drive, and any folder, but the recommendation is to put all the PHP stuff in a folder just off of the root drive, like C:\PHP, and this guide will follow that recommendation.


1.2 Rename/copy php.ini-recommended to php.ini

In your PHP directory, you'll find a couple of php.ini-* files.  They are pre-configured settings for a PHP install that you can use as an initial setup.  php.ini-recommended is the most secure, hence, the recommended one; just rename it to php.ini, overwriting any existing php.ini.


*************************
2. Configure PHP, mainly editing php.ini
*************************


2.1 Uncomment "cgi.force_redirect" in php.ini and set equal to 0

*** This is a very important step, don't neglect it. ***


2.2 Download browscap.ini (I got it from http://www.garykeith.com/browsers/downloads.asp - php_browscap.ini) to C:\PHP\extras\browscap.ini
2.3- Uncomment and edit the browscap variable in php.ini to point to C:\PHP\extras\browscap.ini

You don't _have_ to install a browscap file, it's just for those who want to use the browser identification features of PHP.  It's pretty straightforward: download php_browscap.ini from the above website to the extras directory under your PHP install directory, and change the variable in php.ini to point to the browscap file.


2.4 Grant IUSR Read and Execute, and Read permissions  on php.ini

This is so that the unauthenticated Internet User (under which PHP will run in a website) will have read access to the configuration file.
Right-click on your newly-created php.ini file, then click on "Properties" in the list that pops up.  This will open a dialog box with several tabs.  One of the tabs is named "Security".  Click on it.  This tab shows a list of users who have permission to access the file.  Click on the "Add" button, then enter in the rather large text box, "IUSR_<SERVERNAME>".  Click on "Check Names" to have it find the user for you.  If it can't find the username, a "Name Not Found" dialog box will display.  In that case, "Cancel" the "Name Not Found" dialog, then click the "Advanced" button.  This will open another dialog, where you'll click on the "Find Now" button, then scroll through the list of  "Search results" to find the Internet Guest account (Probably displayed as IUSR_<SERVERNAME>).  If you can't find the
Internet Guest account, then make sure IIS is installed and enabled, which is a whole 'nother subject. :-)
Once you find the Internet Guest Account, "OK" your way out of all dialogs.  The default permissions are Read and Execute, and Read.  You can probably uncheck the Read and Execute checkbox, although I left the default permissions.


2.5 Create a session state directory, grant IUSR full control to it, and point "session.save_path" in php.ini to it.

If you need to use PHP sessions, be sure to uncomment and change session.save_path to point to a valid directory somewhere to which IUSR has full control permissions.  I created a "C:\PHP\Sessions" directory.  I haven't explicitly tested this yet, I'm following the directions of others.


2.6 set "extension_dir" in php.ini to "C:\PHP\ext"
2.7 Uncomment the desired extensions in php.ini (search for "extension=")
2.8 Do one of two things:
        a. Copy all non-php dll files from C:\PHP to C:\Windows\System32 (or somewhere else in the server's PATH)
        OR
        b. Add "C:\PHP" to the server's PATH environment variable
                - right-click on My Computer, choose Properties
                - flip to the Advanced tab
                - click the Environment Variables button
                - Double-click the Path variable in the list of System variables.
                - Either add "C:\PHP;" to the beginning, or ";C:\PHP" to the end.
                - Re-boot the server for it to take effect.
2.9 If you're going to use MySQL 4.1.5 or later, add the line, "extension=php_mysqli.dll" to the ini file, right after "extension=php_mysql.dll".  As a side note, phpBB2 does not work with MySQL 4.1.x or PHP 5.x.

If you want to use php extensions, you'll have to change the value of extension_dir in php.ini to be <PHP install dir>\ext (for PHP 5) and uncomment the applicable "extension=..." lines, then place the helper library files somewhere in the server's PATH, either by copying them, or modifying the PATH.  I couldn't get some of the extensions to work, but most of them did.
The MySQL connector has to be mysqli for MySQL 4.1.5 or later.


2.10 Add to the registry HKEY_LOCAL_MACHINE\SOFTWARE\PHP\IniFilePath = C:\PHP

This is so that PHP can find its configuration file.  To make it easy on you, modify the following text between the dashes so that "C:\\PHP" is the directory in which you've unzipped PHP, then copy the text (sans dashes) and paste into a new text file (anywhere, the Desktop is a good place to create it).  Rename the file to "inifilepath.reg", then double-click on it, click "Yes" to the confirmation dialog, and the value will be in place.  You can then delete inifilepath.reg.
---------------------------------------------------------
Windows Registry Editor Version 5.00

[HKEY_LOCAL_MACHINE\SOFTWARE\PHP]
"IniFilePath"="C:\\PHP"
---------------------------------------------------------


*************************
3. Configure IIS
For the rest of the steps, open IIS Manager (Start->Control Panel->Administrative Tools->Internet Information Services (IIS) Manager).
*************************

3.1 Add and allow the PHP ISAPI Extension to IIS Web Service Extensions: C:\PHP\php5isapi.dll

When you open IIS Manager, it should connect to the local computer automatically.  Expand the local computer in the left pane, then click on "Web Service Extensions" in the left pane.
In the right pane, now, click the blue underlined text, "Add a new Web service extension...".  Enter "PHP ISAPI Extension" as the "Extension name", then click the "Add..." button and browse to the php5isapi.dll file in your PHP install directory.
There are two ways to setup PHP for the web: ISAPI and CGI.  ISAPI is typically more efficient and secure.  If you want to add the CGI extension, in addition to or instead of the ISAPI, repeat the above, but enter "PHP CGI Extension" as the "Extension name", and browse to php-cgi.exe in your PHP install directory for the "Required files".
Once you've named it appropriately and chosen the desired file, check the "Set extension status to Allowed" checkbox and click "OK".


The following two steps are suggested to apply to the "Web Sites" root folder in IIS Manager, but they can be applied to individual sites, instead.  When applying changes to "Web Sites", note that a dialog might come up asking if you want to apply changes to a list of specific websites, too.  Note that the listed sites will be ones that have overridden any default values, so be careful about applying changes to them.  Especially be careful of applying changes to the Microsoft SharePoint Administration site (thus speaks painful experience).


3.2 Right-click on "Web Sites", goto Properties->Home Directory->Configuration...->Application Extensions, add a new extension: .php using C:\PHP\php5isapi.dll; allow GET,POST,HEAD.  This will apply to every website.

This sets up IIS to actually respond to requests for php files.  "Web Sites" is a "folder" in the left pane of IIS Manager.  php5isapi.dll will be in your PHP install directory.  Replace php5isapi.dll with php-cgi.exe if you chose the CGI extension.


3.3 Turn on scripting permissions for your websites

Right-click on "Web Sites", goto Properties->Home Directory.
Change the "Execute permissions" dropdown to "Scripts only".


You made it, configuration is all done!


3.4a Restart IIS

Right-click the local computer in the left pane of IIS Manager, click on All Tasks->Restart IIS...->OK

*** OR ***

3.4b Reboot server

Only if you modified the server's PATH environment variable for the extensions and haven't rebooted yet.


*************************
4. Test your setup
*************************

4.1 Create a new file named test.php in one of the websites containing the single line below:
<? phpinfo(); ?>

Expand the "Web Sites" folder in the left pane of IIS Manager to see a list of existing websites.  Right-click->Properties->Home Directory->Local Path will show you where the website root directory is.

4.2 Point browser there to test.

*** NOTE ***
If you uncommented extensions, be sure to test this from the server's console, not another computer, or even Terminal Services.  Some of the extensions don't work, and an error dialog will pop up on the server console telling which one didn't work.  You have to be able to click "OK" to the dialog for the page to finish loading.  Take note of the extension that didn't work, click "OK", and then comment out the extension in php.ini until you can figure out how to get it to work.

!!!!!!!!!!!! NOTICE !!!!!!!!!!!

This guide is no longer being maintained.
You will find the most up-to-date information
in a much better-looking html-formatted guide at

http://www.peterguy.com/php/install_IIS6.html

Please go there now. :-)

!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
国外的一篇在IIS6上安装PHP5的教程国外的一篇在IIS6上安装PHP5的教程2006-12-18 14:44:01国外的一篇在IIS6上安装PHP5的教程2006-12-18 14:44:01国外的一篇在IIS6上安装PHP5的教程
处理 SSI 文件时出错
  • 上一篇文章:

  • 下一篇文章:
  • 进入论坛讨论

    相关文章
    IIS配置:如何实现访问时要求用户名密码及保护文件?
    IIS+PHP+MySQL+Zend Optimizer+GD库+phpMyAdmin安装配置
    如何在Windows Server 2003 的IIS6下安装PHP5.X
    关于Win2003 IIS配置asp的问题
    Apache 2 + php 5 + mysql 5 在Windows下的安装与配置详解(最新版)
    彻底掌握IIS6.0功能及应用详解
    Windows2003基本的web服务器安全设置
    15条Windows 2003操作技巧
    win2003编写asp代码要注意的地方
    win2003使用ISAPI_Rewrite方法
    怎么计算WEB服务器的最大负载量?
    基于网格的面向专业的Web信息检索体系
    热门文章最新推荐

    版权与免责声明:
    ① 本网转载其他媒体稿件是为传播更多的信息,此类稿件不代表本网观点,版权归原作者所有,本网不承担此类稿件侵权行为的连带责任。
    ② 本站原创文章,转载时请注明出自文谷及作者姓名
    ③在本网BBS上发表言论者,文责自负。
    ④如您因版权等问题需要与本网联络,请在30日内联系 。
    国外的一篇在IIS6上安装PHP5的教程国外的一篇在IIS6上安装PHP5的教程2006-12-18 14:44:01国外的一篇在IIS6上安装PHP5的教程2006-12-18 14:44:01国外的一篇在IIS6上安装PHP5的教程
    国外的一篇在IIS6上安装PHP5的教程国外的一篇在IIS6上安装PHP5的教程2006-12-18 14:44:01国外的一篇在IIS6上安装PHP5的教程2006-12-18 14:44:01国外的一篇在IIS6上安装PHP5的教程

    全站热点
    最新推荐
    处理 SSI 文件时出错
    处理 SSI 文件时出错