WindowsIISPHP5.2 installation and configuration _ php instance

Source: Internet
Author: User
Tags sapi
The installation of PHP in Windows is simple, but if you do not pay attention to the method, it will still give you a headache. In addition, the PHP5.2 version is different from the previous 4.x version, so it is necessary to record it to avoid forgetting this installation and configuration method next time. Step 1: Download the installation package of php 5.2 for windows and decompress it to C: \ php. Note that the extracted directory can be on any disk, but the directory name cannot contain spaces;
The following is the php5.2 file directory:
C: \ php

-- Dev

|-Php5ts. lib

-- Ext -- extension DLLs for PHP



| -..

-- Extras

| -- Mibs -- support files for SNMP

| -- Openssl -- support files for Openssl

| -- Pdf-related -- support files for PDF

|-Mime. magic

-- Pear -- initial copy of PEAR

|-Go-pear.bat -- PEAR setup script

|-Fdftk. dll

| -..

| -Php-cgi.exe -- CGI executable

| -Php-win.exe -- executes scripts without an opened command prompt

| -Php.exe -- CLI executable-ONLY for command line scripting

| -..

|-Php. ini-dist -- default php. ini settings

|-Php. ini-recommended -- recommended php. ini settings

|-Php5activescript. dll

|-Php5apache. dll

|-Php5apache2. dll

| -..

|-Php5ts. dll -- core PHP DLL

| -...

Step 2: Set php under the c: \ php Directory. ini-recommended (or php. ini-dist file, which is officially recommended) copy to the current directory and change the file name to php. ini;

Step 3: Edit php. ini. Modify the values of the following two rows:
Extension_dir = "c: \ php \ ext"
Doc_root = "c: \ inetpub \ wwwroot"

You need to delete the comments at the beginning of the two rows. The value of extension_dir is the ext directory under the php installation directory, and the value of doc_root is the main directory set by IIS;

Step 4: Set environment variables. Add the following values after Path:
;: \ Php
Then restart the computer.

Step 5: open Internet Information Service, find "default website", and stop the website. Then open the "properties" page. On the "properties" Page, find the "home directory" tab and click "Configure" to add the application ing. The values are:
Executable File: c: \ php \ php5isapi. dll
Extension:. php
You do not need to modify other settings. After confirmation, restart the default website;

Step 6: Create a new file hello. php under c: \ inetpub \ wwwroot. Input content:


After saving, open the browser and enter the address http: // localhost/hello. php. If "Hello world" is displayed on the webpage, the installation is correct. You can also view the source code of hello. php on the webpage. If the source code does not contain the php code, the installation is correct.

I have referenced a lot of other people's installation documents and summarized some things, hoping to be useful to everyone ....
1. Two different php installation modes-CGI Mode and modular installation mode
In the cgimodel, if the client requests a php file, the webserver calls php.exe to interpret the file, and then returns the result of the explanation to the client in the form of a webpage. In modularization, php starts and runs with the web server, so from a certain point of view, it is better to install php in apache module mode than CGI Mode, and better execution efficiency and speed.
The following example uses php4.4.0 as an example. It is implemented in a windows xp environment.
1. Install IIS in ISAPI Mode)
(1) decompress the php compressed package to c: \ php \.
(2) Rename php. ini-dist to php. ini and copy it to c: \ windows (windows 2000 to c: \ winnt)
(3) Copy c: \ php \ php4ts. dll to c: \ windows \ system32 (not necessarily required)
(4) IIS5.0 configuration. Open "Control Panel" = "Administrative Tools" = "Internet Service Manager ".
Right-click "Default Web site" and select "properties ".
Click the "ISAPI filter" tab, click "add", and select "php4isapi. dll" for c: \ php \ sapi. The name is PHP.
Click the configuration button in the main directory and click Add in the application configuration dialog box. The Add/edit application extension ing dialog box appears. Click Browse and select php4isapi. dll of c: \ php \ sapi. Extension. php, other default.
2. Install IIS in CGI Mode)
(1) download php's Windows Installer php-4.4.0-installer.exe, which does not include any external php extensions (php _ *. dll ).
(2) follow the step-by-step Installation Wizard. The installation wizard collects sufficient information to set the php. ini file and automatically configures the IIS server. (This is also possible when apache is used as the server, but cannot be automatically configured. It must be manually configured)
(3) After installation is complete, IIS installs CGI-mode php.
3. install Apache (modular installation mode)
Take apache 2.0.55 as an Example
(1) download the installation package apache_2.0.55-win32-x86-no_ssl.exe of apache.
(2) When you run the downloaded Installation File to install the apache installation file, you will be prompted to enter the host name, Administrator mailbox, and other information. After installation, you can go to httpd. conf.
(3) we recommend that you change the default installation path to "c:" To facilitate future operations :"
(4) After the installation is complete, edit the apache2/conf/httpd. conf file.
(5) because IIS uses port 80 by default, we need to change ServerName to "localhost: 81" (row 213) and the port number to 81 (row 120's listen 80 is changed to listen 81)
(6) load the php-supported apache module php4apache2. dll, and add "LoadModule php4_module c:/php/sapi/php4apache2. dll" to row 134"
(7) load the supported suffix name and add "AddType application/x-httpd-php. php. php3. php4" to the 757 line"
(8) Add the php file name identified by default, locate row 322 of DirectoryIndex, and add "index. php default. php default.htm default.html"
(9) Copy c: \ php \ php4ts. dll to c: \ windows \ system32 (required)
(10) choose Start> Run and enter the cmd command.
(11) Go To The apache2/bin directory and run the apache-k install and apache-k start commands.
(12) Access http: // localhost: 81 to display the APACHE welcome page (apache installation successful)
(13) Place the php program to be debugged under apache2/htdocs to debug the php program.
(14) You can also change the php debugging program to the custom path and modify the DocumentRoot value of httpd. conf.
Configure the server's GD library support:

1. Open the php. ini file, find extension = php_gd2.dll, and remove the semicolon (row 555)
2. Find extension_dir and modify "extension_dir ="./"to install the extensions directory where php is located. My name is extension_dir =" c:/PHP/extensions"
3. Restart the apache server.
Related Article

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: 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.