教你IIS6的PHP最佳配置方法
虽然 LAMP 组合很不错,但是如果想要架设一台同时支持PHP、ASP、ASP.NET、JSP、Perl的Web虚拟主机服务器,还是用 Windows 2003的IIS 6最好。网上有很多介绍在IIS 6上配置PHP的文章,但是那些方法不是性能不好,就是升级麻烦。下面的方法可以让你在第一次配置好后,能够非常方便的进行升级。
这里所说的升级,是指从某个php4版本升级到另一个php4版本,或者从某个php5版本升级到另一个php5版本,而不是指从php4升级到php5。
准备:
1、一台安装好的 Windows 2003 服务器,并且已经安装了 IIS 6。
2、下载 windows 版的 PHP 二进制压缩包
安装:
解压缩 PHP 二进制压缩包到 C:\php 目录下(这里假设 C: 盘是系统盘,即安装了Windows 系统的盘,如果系统盘是 D: 盘,则解压缩到 D:\php 目录下,以此类推,下同)。
然后打开“我的电脑”->“属性”->“高级”->“环境变量”->“系统变量”->“path”,编辑其值,在前面增加下面的路径地址:
C:\php;C:\php\dlls;C:\php\extensions;C:\php\sapi;
将 php.ini-dist 或 php.ini-recommended 复制到 C:\Windows 目录下,并改名为 php.ini,一般正式发布网站的服务器用 php.ini-dist,而作为调试用的服务器用 php.ini-recommended 更好。当然一般情况下,这个 php.ini 还是需要根据实际情况来修改的。
下面来介绍一下几个必要的修改选项:
extension_dir = "C:\php\extensions"
这个是 PHP 扩展所放置的目录,请确保跟你实际安装的目录相同。
extension=php_mbstring.dll
;extension=php_big_int.dll
extension=php_bz2.dll
extension=php_cpdf.dll
extension=php_crack.dll
extension=php_curl.dll
extension=php_db.dll
extension=php_dba.dll
extension=php_dbase.dll
extension=php_dbx.dll
extension=php_domxml.dll
;extension=php_exif.dll
;extension=php_fdf.dll
;extension=php_filepro.dll
extension=php_gd2.dll
extension=php_gettext.dll
extension=php_hyperwave.dll
extension=php_iconv.dll
;extension=php_ifx.dll
;extension=php_iisfunc.dll
extension=php_imap.dll
;extension=php_interbase.dll
extension=php_java.dll
extension=php_ldap.dll
;extension=php_mcrypt.dll
extension=php_mhash.dll
extension=php_mime_magic.dll
extension=php_ming.dll
extension=php_mssql.dll
extension=php_msql.dll
;extension=php_oci8.dll
extension=php_openssl.dll
;extension=php_oracle.dll
extension=php_pdf.dll
extension=php_pgsql.dll
;extension=php_printer.dll
extension=php_shmop.dll
;extension=php_snmp.dll
extension=php_sockets.dll
;extension=php_sybase_ct.dll
extension=php_w32api.dll
extension=php_xmlrpc.dll
extension=php_xslt.dll
extension=php_yaz.dll
extension=php_zip.dll
上面这些,开头没有加分号的是打开的扩展,加了分号的是没有打开的扩展。上面的设置包含了在 Windows 2003 上默认安装情况下可以打开所有扩展(这里列出的是 php 4 的)。
session.save_path = c:\sessions
这个是 session 文件默认保存的目录,这个目录必须是一个存在的目录,不然默认的 session 功能会无效。我这里设置的是一个 ramdisk 上的一个目录。将 session.save_path 设置在 ramdisk 上可以加快 session 处理的速度。如果你没有安装 ramdisk,你可以把它指定到其他盘的任何一个目录下,如 C:\sessions 目录、C:\Windows\Temp 目录等。
OK,基本工作作完了,现在该配置 IIS 了。
打开“ Internet 信息服务(IIS)管理器”,在“ Web 服务扩展”里,选择“添加一个新的 Web 服务扩展”,扩展名可填写“PHP ISAPI 扩展”,要求的文件选择:C:\php\sapi\php4isapi.dll(如果安装的是 PHP5,则此处是 C:\php\sapi\php5isapi.dll,下同),并设置扩展状态为允许。
打开“网站”->“属性”->“ISAPI 筛选器”->“添加”,筛选器名称可填写“PHP”,可执行文件仍然选择 C:\php\sapi\php4isapi.dll。
打开“网站”->“属性”->“主目录”->“应用程序设置”->“配置”->“应用程序扩展”->“添加”,可执行文件还是选择 C:\php\sapi\php4isapi.dll。扩展名填写“.php”,动作限制为“HEAD,GET,POST”。
打开“网站”->“属性”->“文档”->“启用默认内容文档”->“添加”,可以将 index.php 添加为默认内容文档。
然后选择“服务器机器名”->“所有任务”->“重新启动 IIS”来重启 IIS。
测试
在默认网站发布目录下,建立一个测试页面:
下载:phptest.php
phpinfo();
?>
如果打开这个页面能够看到 php 安装配置信息,就算是安装成功了。
如果想要更优化的执行 php 程序,可以安装 ZendOptimizer-2.6.0-Windows-i386.exe ,这个东西安装非常简单,这里就不介绍了。
升级
现在升级就非常简单了。只需要将新版本的 PHP 二进制压缩包下载下来,将原来的 C:\php 目录删除,将新版本解压缩到 C:\php 目录中,然后重新启动一下 IIS 就可以了。不需要修改任何配置,也不需要往 System32 目录中复制任何文件。是不是很方便啊?

Hot AI Tools

Undresser.AI Undress
AI-powered app for creating realistic nude photos

AI Clothes Remover
Online AI tool for removing clothes from photos.

Undress AI Tool
Undress images for free

Clothoff.io
AI clothes remover

AI Hentai Generator
Generate AI Hentai for free.

Hot Article

Hot Tools

Notepad++7.3.1
Easy-to-use and free code editor

SublimeText3 Chinese version
Chinese version, very easy to use

Zend Studio 13.0.1
Powerful PHP integrated development environment

Dreamweaver CS6
Visual web development tools

SublimeText3 Mac version
God-level code editing software (SublimeText3)

Hot Topics



Static binding (static::) implements late static binding (LSB) in PHP, allowing calling classes to be referenced in static contexts rather than defining classes. 1) The parsing process is performed at runtime, 2) Look up the call class in the inheritance relationship, 3) It may bring performance overhead.

JWT is an open standard based on JSON, used to securely transmit information between parties, mainly for identity authentication and information exchange. 1. JWT consists of three parts: Header, Payload and Signature. 2. The working principle of JWT includes three steps: generating JWT, verifying JWT and parsing Payload. 3. When using JWT for authentication in PHP, JWT can be generated and verified, and user role and permission information can be included in advanced usage. 4. Common errors include signature verification failure, token expiration, and payload oversized. Debugging skills include using debugging tools and logging. 5. Performance optimization and best practices include using appropriate signature algorithms, setting validity periods reasonably,

What are the magic methods of PHP? PHP's magic methods include: 1.\_\_construct, used to initialize objects; 2.\_\_destruct, used to clean up resources; 3.\_\_call, handle non-existent method calls; 4.\_\_get, implement dynamic attribute access; 5.\_\_set, implement dynamic attribute settings. These methods are automatically called in certain situations, improving code flexibility and efficiency.

Why can't my code get the data returned by the API? In programming, we often encounter the problem of returning null values when API calls, which is not only confusing...

Mastering Debian system log monitoring is the key to efficient operation and maintenance. It can help you understand the system's operating conditions in a timely manner, quickly locate faults, and optimize system performance. This article will introduce several commonly used monitoring methods and tools. Monitoring system resources with the sysstat toolkit The sysstat toolkit provides a series of powerful command line tools for collecting, analyzing and reporting various system resource metrics, including CPU load, memory usage, disk I/O, network throughput, etc. The main tools include: sar: a comprehensive system resource statistics tool, covering CPU, memory, disk, network, etc. iostat: disk and CPU statistics. mpstat: Statistics of multi-core CPUs. pidsta

Efficient reading of Windows system logs: Reversely traverse Evtx files When using Python to process Windows system log files (.evtx), direct reading will be from the earliest...

Choice of Python Cross-platform desktop application development library Many Python developers want to develop desktop applications that can run on both Windows and Linux systems...

Python binary library (.whl) download method explores the difficulties many Python developers encounter when installing certain libraries on Windows systems. A common solution...
