安全基础之IIS 6 的 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”,编辑其值,在前面增加下面的路径地址:
<ccid_code>C:\php;C:\php\dlls;C:\php\extensions;C:\php\sapi;</ccid_code> Copy after login |
下面来介绍一下几个必要的修改选项:
<ccid_code>extension_dir = "C:\php\extensions"</ccid_code> Copy after login |
<ccid_code>extension=php_mbstring.dll;extension=php_big_int.dllextension=php_bz2.dllextension=php_cpdf.dllextension=php_crack.dllextension=php_curl.dllextension=php_db.dllextension=php_dba.dllextension=php_dbase.dllextension=php_dbx.dllextension=php_domxml.dll;extension=php_exif.dll;extension=php_fdf.dll;extension=php_filepro.dllextension=php_gd2.dllextension=php_gettext.dllextension=php_hyperwave.dllextension=php_iconv.dll;extension=php_ifx.dll;extension=php_iisfunc.dllextension=php_imap.dll;extension=php_interbase.dllextension=php_java.dllextension=php_ldap.dll;extension=php_mcrypt.dllextension=php_mhash.dllextension=php_mime_magic.dllextension=php_ming.dllextension=php_mssql.dllextension=php_msql.dll;extension=php_oci8.dllextension=php_openssl.dll;extension=php_oracle.dllextension=php_pdf.dllextension=php_pgsql.dll;extension=php_printer.dllextension=php_shmop.dll;extension=php_snmp.dllextension=php_sockets.dll;extension=php_sybase_ct.dllextension=php_w32api.dllextension=php_xmlrpc.dllextension=php_xslt.dllextension=php_yaz.dllextension=php_zip.dll</ccid_code> Copy after login |
上面这些,开头没有加分号的是打开的扩展,加了分号的是没有打开的扩展。上面的设置包含了在 Windows 2003 上默认安装情况下可以打开所有扩展(这里列出的是 php 4 的)。
<ccid_code>session.save_path = c:\sessions</ccid_code> Copy after login |
这个是 session 文件默认保存的目录,这个目录必须是一个存在的目录,不然默认的 session 功能会无效。我这里设置的是一个 ramdisk 上的一个目录。将 session.save_path 设置在 ramdisk 上可以加快 session 处理的速度。如果你没有安装 ramdisk,你可以把它指定到其他盘的任何一个目录下,如 C:\sessions 目录、C:\Windows\Temp 目录等。
好了,基本工作做完,现在该配置 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
<ccid_code><?php phpinfo(); ?></ccid_code> Copy after login |
如果打开这个页面能够看到 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



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,

In PHP8, match expressions are a new control structure that returns different results based on the value of the expression. 1) It is similar to a switch statement, but returns a value instead of an execution statement block. 2) The match expression is strictly compared (===), which improves security. 3) It avoids possible break omissions in switch statements and enhances the simplicity and readability of the code.

In PHP, you can effectively prevent CSRF attacks by using unpredictable tokens. Specific methods include: 1. Generate and embed CSRF tokens in the form; 2. Verify the validity of the token when processing the request.

Solving the problem of slow Photoshop startup requires a multi-pronged approach, including: upgrading hardware (memory, solid-state drive, CPU); uninstalling outdated or incompatible plug-ins; cleaning up system garbage and excessive background programs regularly; closing irrelevant programs with caution; avoiding opening a large number of files during startup.

In PHP, the final keyword is used to prevent classes from being inherited and methods being overwritten. 1) When marking the class as final, the class cannot be inherited. 2) When marking the method as final, the method cannot be rewritten by the subclass. Using final keywords ensures the stability and security of your code.

Yes, MySQL can be installed on Windows 7, and although Microsoft has stopped supporting Windows 7, MySQL is still compatible with it. However, the following points should be noted during the installation process: Download the MySQL installer for Windows. Select the appropriate version of MySQL (community or enterprise). Select the appropriate installation directory and character set during the installation process. Set the root user password and keep it properly. Connect to the database for testing. Note the compatibility and security issues on Windows 7, and it is recommended to upgrade to a supported operating system.

How to implement Windows-like in front-end development...

How to distinguish between closing tabs and closing entire browser using JavaScript on your browser? During the daily use of the browser, users may...
