Security Basics-The PHP best configuration method for IIS 6

Source: Internet
Author: User
Tags filter iis ini sapi sessions variable

The LAMP combination is good, but if you want to set up a Web virtual host server that supports PHP, ASP, ASP.net, JSP, Perl, or IIS 6 with Windows 2003, it's best. There are a lot of articles on the web that describe PHP on IIS 6, but those methods are not bad performance or upgrade trouble. The following method allows you to upgrade very easily after the first configuration.

The upgrade referred to here refers to upgrading from one PHP4 version to another PHP4 version, or upgrading from one PHP5 version to another PHP5 version, rather than upgrading from PHP4 to PHP5.

Preparation:

1, a installed Windows 2003 server, and has installed IIS 6.

2, download the Windows version of the PHP binary compression package.

Installation:

Unzip the PHP binary compression package into the C:\php directory (assuming C: disk is the system disk, that is, the disk of Windows system is installed, if the system disk is D: disk, then unzip to the D:\php directory, and so on, the same below).

Then open "My Computer"-> "->" "Advanced"-> "Environment variable"-> "System variable"-> "path", edit its value, and add the following path address above:

       
        
         
        C:\php; C:\php\dlls; C:\php\extensions; C:\php\sapi;
       
        
Copy the Php.ini-dist or php.ini-recommended to the C:\Windows directory, and rename it to php.ini, the server that officially publishes the website uses php.ini-dist, and as the server used for debugging uses php.ini-recommended better. Of course, under normal circumstances, this php.ini still need to be modified according to the actual situation.

Here are some of the necessary modification options:

       
        
         
        Extension_dir = "C:\php\extensions"
       
        
This is the directory where the PHP extensions are placed, make sure you are the same as the directory you are actually installing.

       
        
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 
       

The above, with no semicolon at the beginning, is an open extension, and a semicolon is an extension that is not open. The above settings include all extensions that can be turned on by default installation on Windows 2003 (PHP 4 is listed here).

       
        
         
        Session.save_path = C:\sessions
       
        

This is the default save directory for the session file, which must be a directory that exists, or the default sessions function will not work. I'm setting up a directory on a RAMDisk. Setting the Session.save_path on RAMDisk can speed up session processing. If you do not have RAMDisk installed, you can assign it to any of the other disks, such as C:\sessions directory, C:\Windows\Temp directory, and so on.

OK, the basic work is done, now it's time to configure IIS.

Open Internet Information Services (IIS) Manager, and in Web service extensions, select Add a new Web service extension, and the extension can fill in the PHP ISAPI extension, the requested file selection: C:\php\sapi\ Php4isapi.dll (if the PHP5 is installed, this is C:\php\sapi\php5isapi.dll, below), and the extension status is set to allow.

Open the Web site-> Properties-> ISAPI Filter-> Add, the filter name can be filled in "PHP", and the executable file still chooses C:\php\sapi\php4isapi.dll.

Open the Web site-> Properties-> The home directory-> application settings-> configuration-> Application Extensions-> Add, or choose C:\php\sapi\php4isapi.dll for the executable file. The extension is filled with ". PHP" and the action is limited to "head,get,post".

You can add index.php as the default content document by opening the Web site-> Properties-> document-> enable default content document-> Add.

Then select the server machine name-> "All Tasks"-> "Restart IIS" to restart IIS.

Test

In the default Web site publishing directory, create a test page:

Download: phptest.php

       
        
         
        <?php phpinfo ();?>
       
        

If you open this page to see the PHP installation configuration information, even if the installation is successful.

If you want to optimize the execution of PHP program, you can install Zendoptimizer-2.6.0-windows-i386.exe, this thing installation is very simple, here is not introduced.

Upgrade

Now the upgrade is very simple. Just download the new version of the PHP binary compression pack, remove the original C:\php directory, unzip the new version to the C:\php directory, and then restart IIS. You do not need to modify any configuration, and you do not need to copy any files to the System32 directory. Isn't it convenient?



Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.