How to configure IIS to support PHP, ISAPI, CGI, and FastCGI (latest php5.2.13 configuration method)

Source: Internet
Author: User
Tags dbase sapi website server

In IIS6 of Windows Server 2003, configure the ISAPI-based PHP by adding a new WEB Service extension in IIS's "WEB Service extension". The program suffix is PHP, the ISAPI program is php5isapi. dll, and then add the variable name PHPRC to my computer-> properties-> advanced-> "environment variable"-"system variable". The value is php. ini path. In Internet Information Service Manager, select the root directory of the website or application, open the directory properties page (right-click and select "properties"), and then select "main directory ". Click the "configuration" button and select the "ing" Tab. Click "add... in the "executable file", set it to c: \ php \ php5isapi. dll, with the extension set. php, select "check whether the file exists", and then "OK" to save the settings. Restart the server to complete the PHP configuration.

The above red part does not need to be done, because the ISAPI is used with PHP, and the system variable is not read (read only in CGI Mode). The related permission settings are as follows:
<Configure the read permission for "IUSR _ ***" in the folder where the webpage is located. If you want to write, modify the permission.
Configure the read permission for "network service" and "IUSR _ ***" in the PHP file folder.
Php. ini file to "network service" Read Permission
To obtain the DLL file in the SYSTEM32 directory, you must grant "IUSR _ **" read and run permissions.

Decompress the PHP binary package to the D: \ php Directory.
Choose "my computer"> "properties"> "advanced"> "environment variables"> "system variables"> "path" to edit the value, add the following path
Address:
; D: \ php \ ext (note the semicolon above)

When using IIS to integrate php, there are two methods: ISAPI and CGI Mode. We can see the phpinfo page in both methods, but the ISAPI mode cannot read environment variables, therefore, php is set through the Environment Variable PHPRC. the ini path cannot be found. You can use CGI to copy many files to the system file.


The configuration file (php3.ini in PHP 3 and PHP. ini from php 4) is read at PHP startup. For PHP of the server module version
The web server is read once at startup. For CGI and CLI versions, each call will read.
The search path for php. ini is as follows (in order ):
* Position specified by the SAPI module (PHPIniDir command in Apache2,-c command line option in CGI and CLI, NSAPI
The php_ini parameter in, and the PHP_INI_PATH environment variable in THTTPD)
* HKEY_LOCAL_MACHINE \ SOFTWARE \ PHP \ IniFilePath (Windows Registry location)
* PHPRC Environment Variables
* Current working directory (for CLI)
* Web Server Directory (for SAPI module) or PHP Directory (for other Windows scenarios)
* Windows Directory (C: \ windows or C: \ winnt), or the location specified by the -- with-config-file-path option during compilation

I met this problem in the Server2003 + php4 environment. The solution is to add a PHPRC when writing the PATH environment variable, pointing to x: \ php4 \ php. ini, restart it. If it still doesn't work, the last step is to install the zend and php accelerators, because when zend is installed, php will be specified. the ini path also specifies whether the server is IIS or Apache. In essence, the Registry is modified, but I don't know where to change it, so when the above operation is still invalid, I finally installed Zend and finally solved the problem.

Copy php. ini-dist or php. ini-recommended to the C: \ Windows directory and change the name to php. ini.
Generally, php. ini-recommended is used for the server that officially releases the website to ensure high security.
Php. ini-dist is better for servers used for debugging.
Of course, in general, this php. ini still needs to be modified according to the actual situation.
The following describes several necessary modification options:
Copy libmysql. dll to the System32 directory
Extension_dir = "D: \ php \ ext"
This is the directory where PHP extensions are placed. Make sure that the directory is the same as the one you actually installed.
Set the correct time zone:
Locate "date. timezone" and set it to date. timezone = PRC.
The following operations enable or disable PHP extensions selectively:
Extension = php_mssql.dll
Extension = php_mysql.dll
In the above cases, the open extension is not given a plus sign at the beginning, and the extension that is not opened is added with a semicolon.
Session. save_path = c: \ sessions
This is the default session file directory, which must be an existing Directory. Otherwise, the default session function will be invalid. Here I set a directory on a ramdisk. Setting session. save_path on ramdisk can speed up session processing. If ramdisk is not installed, you can specify it to any directory of other disks, such as the C: \ sessions directory and C: \ Windows \ Temp directory.
OK. The basic work is finished. Now it is time to configure IIS.
Open "Internet Information Service (IIS) manager", select "Add a new Web Service extension" in "Web Service extension", and enter the extension
For "php isapi extension", select D: \ php \ php5isapi. dll as the required file. (If PHP4 is installed, C: \ php \ sapi \ php4isapi. dll is used here.
And set the scaling status to allow.
Open "website"-> "properties"-> "ISAPI filter"-> "add", enter "PHP" as the filter name, and select the executable file
D: \ php \ php5isapi. dll.
Choose "website"> "properties"> "main directory"> "application settings"> "configuration"> "application extension"> "add ", executable File or select
<> Open "website"> "properties"> "document"> "enable default content document"> "add" to enable index. add php as the default content document.
Select "server machine name"> "all tasks"> "restart IIS" to restart IIS.
Test
Create a test page under the default website release directory:
Download: phptest. php
Phpinfo ();
?>
If the php installation configuration information is displayed on this page, the installation is successful.
If you want to better execute the php program, you can install the ZendOptimizer-2.6.0-Windows-i386.exe, this installation is very simple, it is not introduced here
.
Upgrade
Now the upgrade is very simple. Download the PHP Binary Package of the new version, delete the original D: \ php Directory, and decompress the new version
<Body system32 iis>
Loading of the IIS php filter php5isapi. dll failed.

Cause: the server has made security settings and removed the everyone permission of d: \ php. IIS naturally cannot load php5isapi. dll.
Solution: add the "d: \ php" directory and the "everyone" user to set the permission to "read-only ".

Two of the most difficult problems I have encountered are: php5isapi. dll is not loaded and MySQL cannot be started normally. Now I will share my solution.

[Php5isapi. dll not loaded ]:
After setting on IIS, "all unknown ISAPI extensions" and "Active server pages" in the WEB service extension are enabled, but the php5isapi written in the ISAPI filter is returned. dll is either "status: Unknown" (No icon) or "Status: Not started" (red down arrow icon ).
Solution:
1. first, determine that the permission restriction is caused by two parts: System File Permission and Server Extension permission. First, go to the location where the ISAPI Linked Library file is located, then, grant the full control permission to the file EveryOne (you can also select a combination of read, write, and execution permissions ).
2. solve the Problem of Server Extension permissions: Go to the "Server Extension" setting page of IIS6.0. If you want to save trouble, you can directly click the "allow all unknown isapis" button, but I do not recommend this. This is too insecure! We should add a new server extension here. You can fill in the extension as needed, select the ISAPI Linked Library file, select "set status to allow", and save.
3. To make the settings take effect, restart the system. After the restart, your ISAPI extensions can be loaded normally!

[MySQL cannot be started normally]
The general reason is that it has been installed before, and is now upgraded or uninstalled in the control panel and then re-installed. I will not mention the upgrade, which is generally caused by my. ini. The most troublesome problem for new users is that they have not been uninstalled completely. After I reinstall mysql, the project cannot be started normally in the windows Service. The error message is: 1067.
There are five steps to completely clear mysql: (my system is 2003 server, please note !)
1. Do not rush to the control panel to uninstall. In cmd, enter the bin directory under mysql, execute mysqld-nt-remove, and close the window when prompted.
2. Uninstall the control panel.
3. my operating system is 2003 server, so my is not in the windows directory. the INI file does not need to be cleared manually. You only need to delete the previously installed path folder. Remember to delete it completely, instead of migrating it to the recycle bin.
4. Execute regedit under cmd, enter the registry, search for the keyword mysql, and delete all the records of the system disk. Of course, either of the two may be non-system disks written to the project, which doesn't matter. Press the F3 key to find the next one until all search is complete. (New users remember to back up the Registry first !)
5. Restart.
The preceding five steps can be completely cleared. After the installation is complete, you can start the service and save the security settings in the basic MySQL Server Instance Config Wizard settings.
This is the 5-point operation that a new employee summed up after encountering the 1067 error. It may seem simple, but it may be helpful to some friends who are also new people. Thank you for your advice.

In System Configuration of 2003, some permissions are not properly set for a long time. Here, we will share some experiences for your reference and future reference.
1. Check the PHP. ini file permission in the directory and grant the EVERYONE read permission;
2. Check the PHP5ISAPI. DLL file permission in the directory and grant the EVERYONE read permission;
3. If the problem persists in the preceding two steps, cancel IIS installation in system component configuration of the Add/delete program, reinstall IIS, and set the ISAPI module of PHP.

I. When you run the phpmyadmin program, the following solution is displayed: "mysql extension cannot be loaded. Check the PHP configuration:
A:
The Mysql database is not correctly installed, and Mysql-related services are not started in the System Service (Please carefully read the Mysql and php installation tutorial)

II. Install Discuz! When the Forum prompts "the Mysql database is not supported and the forum cannot be installed", the solution is as follows:
A:
1. libmysql is missing in the system32 (C: \ windows \ system32) Directory of the system. dll file. The solution is to find libmysql in the php Directory. dll, and libmysql. dll copied to the C: \ windows \ system32 directory
2. php. in the INI file, the previous ";" in "; extension = php_mysql.dll" is not removed, so the corresponding function cannot be used. The solution is to open php. INI file found
; Extension = php_mysql.dll
Change
Extension = php_mysql.dll // remove the previous one to make it take effect.
3. The correct permissions for the Mysql installation directory are as follows:
Full system control
Only the preceding two permissions are required for the Mysql installation directory, and all other user permissions are deleted.

Important: Check the permissions of the php. ini file, the permissions of the php file copied to system32, And the permissions of the php installation directory folder. At least the default permissions of users are required;

The TEMP folder in the WINDOWS directory of drive C must have at least the USERS Group modification level permission.

We strongly recommend that you configure it in the newly installed standard 2003 system! Configure the environment installer first, and then perform system security settings after the installation is successful!

(Restart the server)

If none of the above are validSo: http://www.jb51.net/softs/26224.html
The automatic installation package for off-star PHP5.2.11 is fast and can be installed on non-star systems. This version is installed on drive C for friends who have not configured the php environment for iis, in fact, it is also good to install on your own, generally installed on a D disk and other non-system installation disks. Php5.2.12 is better supported by the latest win2003, although it is not the latest.
Phpmyadmin error:
Fatal error: session_start () [<a href = 'function. session-start'> function. session-start </a>]: Failed to initialize storage module: files (path:) in D: \ f4jgwy \ jgwynet \ web \ pmbba \ libraries \ session. inc. php on line 75
There are two solutions:
1. Add the following code before session start () in the file where the error is reported: ini_set ('session. save_handler', 'files ');. This method is suitable for users who rent a space.
2. In the php. ini file, explicitly specify the save_path (such as c:/tmp) of the session and restart the web service. If the management permission of the server belongs to you, it is more convenient to change it.
Cancel; session. save_path = "/tmp" comment
Cause analysis: a security mode bug in php5. The save_path of the default session is the temporary directory of the system, which requires permission verification.

PhpMyAdmin-Error
You cannot create a session when an error occurs. Check the PHP or website server logs and correctly configure PHP installation.
Solution:
1. Restart the mysql service to solve the problem. -- invalid
2. Find the php5.ini file and find
Session. save_path = "D: \ xampp \ tmp"
Know the session storage directory, and then go to the d: \ xampp \ tmp directory to clear all the files,
Go to phpmyadmin again. Everything is normal. ---- Invalid
3. Open my computer-system installation disk (if it is good, usually drive C)-open the WINDOWS folder-find the Temp directory;
Right-click "Open Properties" and click "Security Options". If not, click "Tools"> "Folder Options"> "View" at the top of the window to share a single file (recommended) "The preceding check box is removed. It is invalid.
4. Use the phpinfo function to check your php installation and check whether the Loaded Configuration item is correctly configured. If the item is displayed as none,

After the server is restarted or IIS is restarted, all sites are in the stopped status and cannot be started automatically. You need to start the site manually.
Solution 1:
My computer-right-click-Manage-services and applications-services. Find:
IIS Admin Service
World Wide Web Publishing Service
Change to "automatic ".
Solution 2:
The server is a Windows 2003 operating system. After IIS is restarted or the server is restarted, all WebSite Services in IIS are stopped. This is depressing for a long time and the websites are manually started one by one, hard to think about the reason, is it related to the installation of the SERV-U?
If it is because of the installation of SERV-U7.1.0.2 reasons, how to make the site automatically run after restarting the machine? According to the query that the SERV-U7.1.0.2 occupies port 80, enter the SERV-U7.1.0.2 settings, turn off the automatic operation can be!
In addition, when you debug a website on the local IIS, the website is stopped by default after IIS is restarted. You can run the netstat-anb command to check whether port 80 is occupied, find the process that occupies port 80 and close it to start the default website. Thunder uses port 80 by default.
Loading php5isapi. dll failed. Data is incorrect. Is 64-bit windows2003 incompatible with PHP5?
Enable 32-bit IIS support in 64-bit windows IIS:
In the end, 1 indicates that 32-bit support is enabled, and 0 indicates that 32-bit support is disabled. Of course, this time should be started. Select 1.
Then restart IIS
Net start iisadmin
Net start w3svc
Mysql_connect () is not supported. Check whether the mysql module is correctly loaded.
Check whether/usr/lib/php/modules/contains mysql. so.
Find the Redhat installation disk and find
Php-mysql-5.1.6-20.el5.i386.rpm
Php-pdo-5.1.6-20.el5.i386.rpm
Upload, install:
Rpm-ivh php-pdo-5.1.6-20.el5.i386.rpm
Rpm-ivh php-mysql-5.1.6-20.el5.i386.rpm
Check the so file: ls/usr/lib/php/modules/
Dbase. so ldap. so mysqli. so mysql. so pdo_mysql.so pdo. so pdo_sqlite.so phpcups. so
Appendix:
1. Check whether apache, mysql, php and its components are correctly installed and whether the service is started.
2. Check dbase. so ldap. so mysqli. so mysql. so pdo_mysql.so in/usr/lib/php/modules /.
Whether pdo. so pdo_sqlite.so phpcups. so mysql. so exists.
If not, find the Redhat installation disk and find
Installation:
3. in/etc/php. ini, add
Extension = mysql. so
4. Restart httpd and mysqld
Solution to Warning: require_once (./libraries/common. inc. php) error after phpMyAdmin is installed
After PHPmyAdmin is installed, the following error occurs during access to IE:

Fatal error: require_once () [function. require]: Failed opening required '. /libraries/common. lib. php '(include_path = '.; c: \ php5 \ pear ') in D: \ php \ phpMyAdmin \ index. php on line 36

After a while of debugging, I finally found the solution:
The upper-level directory permission of the phpMyAdmin installation directory is insufficient. In this case, the "read and run" permission of the IIS Anonymous User is added to the upper-level directory, and the phpmyadmin page is opened successfully!
[Note]:
1. Do not decompress phpmyadmin and install it in the root directory, because anonymous users will have permissions to the root directory.

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.