Home php教程 php手册 Windows7 IIS7下以FastCgi和ISAPI方法安装配置PHP5教程

Windows7 IIS7下以FastCgi和ISAPI方法安装配置PHP5教程

Jun 21, 2016 am 08:53 AM
fastcgi php windows7

  说到PHP环境配置与安装,通常以Apache搭载PHP配置为主,随着PHP版本不断更新,对Windows IIS平台的支持也越来越好,在Windows IIS平台上配置安装PHP环境也越来越方便。

  在完成Windows 7上搭建Apache+PHP+Mysql环境搭建后,我在Windows 7 IIS7平台上对PHP5.2和PHP5.3进行了配置安装,PHP5.3之前版本在Windows IIS平台上的PHP配置方式主要以ISAPI方式进行,而PHP5.3支持IIS以FastCgi方式运行PHP,这两个PHP5版本的配置安装还是有不小的区别,下面详细介绍ISAPI和FastCgi两种方式在IIS上进行PHP配置的方法。

  准备工作

  在完成IIS上进行PHP5安装配置工作之前,首先需要下载PHP5.2和PHP5.3,PHP5.3以php-5.3.2-Win32-VC9-x86为准,具体下载地址请参考PHP环境搭建:Windows7 Apache+PHP+Mysql一文。

  Windows7 IIS7安装

  在进行IIS7 PHP安装配置之前,首先需要安装IIS7,Windows7默认并没有安装IIS,安装过程如下:

  首先进入控制面板,点击程序和功能,再点击左侧打开和关闭Windows功能,勾选Internet Information Services可承载的Web核心,确定安装。

  在完成安装后,在勾选Internet信息服务,选择安装必要的IIS功能,注意由于在配置PHP5.2和PHP5.3时,IIS7中是以ISAPI和FastCgi方式配置PHP的,所以Cgi和ISAPI扩展和ISAPI筛选器务必勾选(此处由于我首先以ISAPI方式配置PHP5.2,我没有勾选Cgi),如图:

安装IIS7

  在完成Windows7 IIS7的安装后,即可在控制面板中的管理工具中看到Internet信息服务管理器选项。

  如何在Windows7 IIS7上以ISAPI方式配置PHP5.2?

  IIS7 PHP5.2配置第一步:php.ini配置

  解压php-5.2.13-Win32-VC6-x86.zip,重命名为php52iis,将其复制到C盘根目录下,将php.ini-list文件名更改为php.ini,打开php.ini进行配置,php.ini的配置与PHP环境搭建:Windows7 Apache+PHP+Mysql基本一样,注意extension_dir的目录指向必须准确,即

1

extension_dir = "C:/php52iis/ext"

  另外在PHP5.2版本中没有date.timezone选项,所以无需设置。

  在完成PHP5.2中php.ini的配置工作后,将其复制至C:\WINDOWS目录下,同时将PHP52iis目录下的libmcrypt.dll,libmysql.dll,php5ts.dll三个文件到C:/windows/System32目录下。

  IIS7 PHP5.2配置第二步:以ISAPI方式配置PHP5.2

  打开IIS,选择网站下的Default Web Site中的ISAPI筛选器进行PHP配置工作,即

添加ISAPI筛选器,选择PHP相应的DLL文件

  然后选择处理程序映射,进行添加脚本映射操作,即

添加脚本映射操作

  在完成上述IIS7的PHP5配置后,有需要说明一下,默认IIS7下的网站,其绑定的端口为80端口,网站目录为%SystemDrive%\inetpub\wwwroot,如果你向我一样在此之前安装配置了Apache+PHP的环境,则需要修改默认网站绑定的端口及网站目录,如将80端口改为8080,网站目录指向D:\PHPWeb。或者添加一个新网站,即先添加应用程序池,再添加一个网站。

添加应用程序池

添加新网站


添加默认文档

  在完成新网站添加后,请确保处理程序映射中有添加的脚本映射,如果没有,请重复添加脚本映射操作即可。

  IIS7 PHP5.2配置第三步:重启IIS7服务器

  在D:\PHPWeb目录下新建一个index.php文件,内容如下

1
2
3


phpinfo();
?>

  在游览器中输入http://localhost:8080/,查看PHP5.2配置信息。

  至此在Windows7 IIS7上安装配置PHP5.2就算完成了。

  如何在Windows7 IIS7上以FastCgi方式配置PHP5.3?

  在Windows7 IIS7上配置PHP5.3,主要以FastCgi方式进行配置,大体上与PHP5.2的配置基本一样。首先解压php-5.3.2-Win32-VC9-x86,重命名为php53iis并将其复制到C盘根目录。

  IIS7 PHP5.3配置第一步:添加网站

  具体添加过程请参考IIS PHP5.2的配置。

  IIS7 PHP5.3配置第二步:添加FastCgi模块映射

  点击处理程序映射,进行添加模块操作,即

配置IIS以FastCgi方式运行PHP5.3

  IIS7 PHP5.3配置第三步:php.ini配置

  首先将php.ini-development重命名为php.ini,并将

1
2
3

fastcgi.impersonate=1 默认为0,如果使用IIS,你需要开启
cgi.fix_pathinfo=1
cgi.force_redirect=0 默认开启,如果你使用IIS,可以将其关闭

  其次指定extension_dir目录和date.timezone,即

1

extension_dir = "C:/php53iis/ext"

1

date.timezone= Asia/Shanghai

  其他PHP.INI配置与PHP5.2的配置一样,区别在于,在Windows7 IIS7上配置安装PHP时,并不需要将php.ini及其他文件复制到C:/windows及C:/windows/System32目录下,简单很多。

  IIS7 PHP5.3配置第四步:重启IIS7服务器

  同时访问http://localhost:8080/即可。

FastCGI进程意外退出如何解决?

  在使用Windows7 IIS7进行PHP配置安装过程中,如果PHP配置不正确,会出现FastCGI进程意外退出出错信息,此时你可以在DOS下使用

1

C:\php53iis\php.exe -v

进行调试查看,一般情况下会将PHP配置的错误信息报出,你只要根据此信息修改相关PHP配置即可。

  至此在Windows7 IIS7平台上进行PHP5.2和PHP5.3的配置安装工作就介绍完了,应该讲随着PHP版本的提高,PHP的配置工作也越来越简单化。

  :PHP网站开发教程-leapsoul.cn版权所有,转载时请以链接形式注明原始出处及本声明,谢谢。



Statement of this Website
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn

Hot AI Tools

Undresser.AI Undress

Undresser.AI Undress

AI-powered app for creating realistic nude photos

AI Clothes Remover

AI Clothes Remover

Online AI tool for removing clothes from photos.

Undress AI Tool

Undress AI Tool

Undress images for free

Clothoff.io

Clothoff.io

AI clothes remover

Video Face Swap

Video Face Swap

Swap faces in any video effortlessly with our completely free AI face swap tool!

Hot Article

Roblox: Bubble Gum Simulator Infinity - How To Get And Use Royal Keys
3 weeks ago By 尊渡假赌尊渡假赌尊渡假赌
Nordhold: Fusion System, Explained
4 weeks ago By 尊渡假赌尊渡假赌尊渡假赌
Mandragora: Whispers Of The Witch Tree - How To Unlock The Grappling Hook
3 weeks ago By 尊渡假赌尊渡假赌尊渡假赌

Hot Tools

Notepad++7.3.1

Notepad++7.3.1

Easy-to-use and free code editor

SublimeText3 Chinese version

SublimeText3 Chinese version

Chinese version, very easy to use

Zend Studio 13.0.1

Zend Studio 13.0.1

Powerful PHP integrated development environment

Dreamweaver CS6

Dreamweaver CS6

Visual web development tools

SublimeText3 Mac version

SublimeText3 Mac version

God-level code editing software (SublimeText3)

Hot Topics

Java Tutorial
1670
14
PHP Tutorial
1274
29
C# Tutorial
1256
24
PHP: A Key Language for Web Development PHP: A Key Language for Web Development Apr 13, 2025 am 12:08 AM

PHP is a scripting language widely used on the server side, especially suitable for web development. 1.PHP can embed HTML, process HTTP requests and responses, and supports a variety of databases. 2.PHP is used to generate dynamic web content, process form data, access databases, etc., with strong community support and open source resources. 3. PHP is an interpreted language, and the execution process includes lexical analysis, grammatical analysis, compilation and execution. 4.PHP can be combined with MySQL for advanced applications such as user registration systems. 5. When debugging PHP, you can use functions such as error_reporting() and var_dump(). 6. Optimize PHP code to use caching mechanisms, optimize database queries and use built-in functions. 7

PHP vs. Python: Understanding the Differences PHP vs. Python: Understanding the Differences Apr 11, 2025 am 12:15 AM

PHP and Python each have their own advantages, and the choice should be based on project requirements. 1.PHP is suitable for web development, with simple syntax and high execution efficiency. 2. Python is suitable for data science and machine learning, with concise syntax and rich libraries.

PHP and Python: Comparing Two Popular Programming Languages PHP and Python: Comparing Two Popular Programming Languages Apr 14, 2025 am 12:13 AM

PHP and Python each have their own advantages, and choose according to project requirements. 1.PHP is suitable for web development, especially for rapid development and maintenance of websites. 2. Python is suitable for data science, machine learning and artificial intelligence, with concise syntax and suitable for beginners.

PHP in Action: Real-World Examples and Applications PHP in Action: Real-World Examples and Applications Apr 14, 2025 am 12:19 AM

PHP is widely used in e-commerce, content management systems and API development. 1) E-commerce: used for shopping cart function and payment processing. 2) Content management system: used for dynamic content generation and user management. 3) API development: used for RESTful API development and API security. Through performance optimization and best practices, the efficiency and maintainability of PHP applications are improved.

The Enduring Relevance of PHP: Is It Still Alive? The Enduring Relevance of PHP: Is It Still Alive? Apr 14, 2025 am 12:12 AM

PHP is still dynamic and still occupies an important position in the field of modern programming. 1) PHP's simplicity and powerful community support make it widely used in web development; 2) Its flexibility and stability make it outstanding in handling web forms, database operations and file processing; 3) PHP is constantly evolving and optimizing, suitable for beginners and experienced developers.

PHP and Python: Different Paradigms Explained PHP and Python: Different Paradigms Explained Apr 18, 2025 am 12:26 AM

PHP is mainly procedural programming, but also supports object-oriented programming (OOP); Python supports a variety of paradigms, including OOP, functional and procedural programming. PHP is suitable for web development, and Python is suitable for a variety of applications such as data analysis and machine learning.

PHP vs. Other Languages: A Comparison PHP vs. Other Languages: A Comparison Apr 13, 2025 am 12:19 AM

PHP is suitable for web development, especially in rapid development and processing dynamic content, but is not good at data science and enterprise-level applications. Compared with Python, PHP has more advantages in web development, but is not as good as Python in the field of data science; compared with Java, PHP performs worse in enterprise-level applications, but is more flexible in web development; compared with JavaScript, PHP is more concise in back-end development, but is not as good as JavaScript in front-end development.

PHP and Python: Code Examples and Comparison PHP and Python: Code Examples and Comparison Apr 15, 2025 am 12:07 AM

PHP and Python have their own advantages and disadvantages, and the choice depends on project needs and personal preferences. 1.PHP is suitable for rapid development and maintenance of large-scale web applications. 2. Python dominates the field of data science and machine learning.

See all articles