Win2003 under the Environment of PHP development

Source: Internet
Author: User
Tags apache php microsoft sql server sql server driver mssql mssql server vc9 yii

installation configuration and connection of win2003+iis6+php5.3.8+mssql2008
(This method applies to PHP 5.3 and later, SQL Server 2000/2005/2008)
--------------------------------------------------------------------------------------------------------------- --------------
PHP5.3 has not been able to install on IIS in the old way (because PHP 5.3 now does not support ISAPI, it is fastcgi).
(1) Determine that IIS is installed
(2) Download and install IIS FastCGI, download the address: Select x86 or download x86 and download the name for Fcgisetup_1.5_rtw_x86.msi.
The installation succeeds with more than 5 files (fcgi) in the C:\WINDOWS\system32\inetsrv\ directory, and a fastcgi Handler in the Web Service Extensions for IIS 6.

Win7 IIS 7 appears to have fastcgi, or you can install the IIS7 version from the Http:// network (Win2008x86 is also the case, That is, select CGI when installing role IIS
Download the PHP5.3.8 under install IIS, download the address, (note IIS to select the version of VC9) extract to the desired directory (we are D:\App\php), The directory needs to give the user read run permissions.

According to the PHP official website prompts, iis+fastcgi should use the NTS version (not the thread-safe version). And for my Win7 X64, only the 5.5 version (2014may1st result) that was compiled with VC11 is an experimental version. Depending on the test, the 32-bit version can also be used in a compatible manner to work properly.
If your PHP5.3.8 is installed (that is, end of. msi) Install all the software can test the run directly, the installation process has helped you configure the completion. If your PHP5.3.8 is a compressed version (that is, end of. zip) Install the following configuration.
(4) Modification of environment variables. My Computer "advanced" Environment variables system variable path:d:\app\php; (add to the front, if not you can build one yourself.) )
(5) FastCGI installation directory changes (registered PHP to FastCGI).
Open the C:\WINDOWS\system32\inetsrv\fcgiext.ini file, and at the end of the file, add the following statement:
[Types] (This is the original file, in [Types] followed by the following statement can be, to all oh otherwise will be an error. )

(6) Modification of php.ini.
PHP5.3.8 installation directory is not php.ini this file, only Php.ini-development and php.ini-production, we put php.ini-development copy one for php.ini.
Note: First build a folder named TMP, where I put the D:\App\php\tmp. (Upload_tmp_dir will use, Upload_tmp_dir is used to define the temporary path of the upload file storage, you can modify and define an absolute path to it, also need to have read, write permissions). Use Search (shortcut key: ctrl+f) to change the following keyword to the current value:
Short_open_tag = Off (this is the default is so we don't change it.) )
Upload_tmp_dir = Change to Upload_tmp_dir = "D:\App\php\tmp"
Cgi.force_redirect = 1 Change to Cgi.force_redirect=0
Fastcgi.impersonate = 1; change to fastcgi.impersonate=1;
Put Extension_dir = "ext" changed to Extension_dir = "D:\app\php\ext"
Date.timezone = Change to Date.timezone =PRC (if you do not modify the Date.timezone, you may be prompted with a 500 error when you open the page.) Someone also changed the value to Asia/shanghai, I have not tried you can try. )
In Windows extensions, remove the semicolon preceding the extension (;):
(7) Modification of Internet Information Services (IIS) Manager
1) Web site Properties Master Directory configuration add executable file (=c:\windows\system32\inetsrv\fcgiext.dll). name extension =. php. Action "is limited to =get,head,post.

Win7 IIS7 is "handler mapping", add Module Mapping: Request path:*.php, module:Fastcgimodule, executable: "C:\[path to your PHP installation]\php-cgi.exe", name:PHP via FastCGI。 When you are sure, this fastcgi is added and you can set the parameters in the fastcgi in the top level to refer to step 5th.
2) Web Site properties Document add default content =index.php. Win7 IIS7 is to add the default document index.php. It's all configured here, so be sure to restart the IIS service.
(8) test (be sure to restart the IIS service) and finally write a test code with text:
<?phpphpinfo ();>
Save as index.php, name whatever suffix is. php is OK. Put the index.php under the root of the document and then enter or http://localhost/index.php in the browser to get the information back.
Note: No test successful Please do not do the following
(9) Under Windows System, PHP5.3 version no longer supports MSSQL extensions, so if you need to communicate with SQL Server to Ff657782.aspx downloads Microsoft-provided SQL Server Driver for PHP, filename SQLSRV20.EXE (version 2.0 is for SQL Server 2000/2005/2008, if SQL Server 2012, then download SQLSRV30.EXE).
After downloading this EXE can use WinRAR decompression, all (actually only need corresponding). dll files to the Ext folder in the PHP installation directory, then open the php.ini, add the following statement to open the php_sqlsrv and php_pdo_sqlsrv extension:
Note: In fact, there is no need to copy all, as long as the copy you need to use it. General VC6 for Apache (after the trial found that the Apache 2.2.22 is also VC9 compiled, so also with the VC9 version), and VC9 for IIS, as long as the copy of the corresponding two files and then add to the php.ini. As for TS and NTS are thread-safe and not-thread-safe, this is just a choice based on the Php5ts.dll or Php5nts.dll in the PHP directory. Also note the PHP version, we are 5.3.
(10) If you do not install Microsoft SQL Server 2008 R2 Native Client, you must go to (sql.90). aspx download installation, because Microsoft's this expansion pack needs this support.
(11) Write a test to connect SQL Server script, put it under the document root, run the test. Such as:

$serverName = "(local)";
$connectionInfo = Array ("UID" => "* * *", "PWD" => "Hu Jintao", "Database" => "* * *");

$conn = Sqlsrv_connect ($serverName, $connectionInfo);

if ($conn) {
echo "MSSQL Server Connection established.<br/>";
echo "Connection failed!<br/>";
Die (Print_r (Sqlsrv_errors (), true));

if ($conn) {
$query = sqlsrv_query ($conn, "select top * from Tbl_users");
$query = sqlsrv_query ($conn, "select Top * tbl_1213 two experimental arrangement total");
if ($query = = False) {
echo "Error in Query prepareation/execution.\n";
Die (Print_r (Sqlsrv_errors (), true));
while ($row = Sqlsrv_fetch_array ($query, Sqlsrv_fetch_assoc)) {
echo $row [' ID ']. "----". $row [' name ']. " <br/> ";
foreach ($row as $item) {
Echo $item;
Sqlsrv_close ($conn);


Combined with the use of Wamp and cake:

First of all, also make sure that you have installed SQL Server and Microsoft SQL Server 2008 R2 Native Client, prepared the SQL Server Driver for PHP, filename SQLSRV20.EXE (version 2.0 is for sq L server 2000/2005/2008, if SQL Server 2012, download SQLSRV30.EXE.
Download cake and extract to D:\sjg\cakephp-2.3.5
Download Wampserver 32-bit version (PHP 5.3,apache 2.2.22) and install, we are D:\sjg\wamp

Note that the Wampserver Apache in the experiment does not seem to be compatible with Windows 2003 (perhaps the win2003 of the Aliyun host), so we download Apache separately (httpd 2.2.22) and rename the original Apache directory. apache2.2.22, install the downloaded standalone Apache to the original Apache directory (that is, the directory name with apache2.2.22). Use the httpd.exe-k install-n wampapache command to install the Apache service (named in Wampserver, and wamp for consistent and convenient management).

To avoid the 80-port conflict with IIS, we modified the listening port in Apache configuration to listen 8077, and the document root points to the cake document root DocumentRoot "D:\sjg\cakephp-2.3.5\app\webroot". Load PHP module LoadModule php5_module "D:/sjg/wamp/bin/php/php5.3.13/php5apache2_2.dll"

PHP configuration modifications. It is important to note that in Wamp, Apache PHP is configured with the php.ini in the Apache directory, and the configuration must be modified for this INI file. So, copy the php.ini from the old ~apache2.2.22 directory to the apache2.2.22 directory and copy Php5nsapi.dll and Php5ts.dll. Add to SQL Server driver support and IIS, put two files in the Ext directory, php.ini add the corresponding configuration.
Cake's database configuration: When using SQL Server, the cake database is configured to
Public $default = Array (
' DataSource ' => ' Database/sqlserver ',
' Persistent ' => false,
' Host ' => ' (local),
' Login ' => ' * * *,
' Password ' => ' * * *,
' Database ' => ' * * * *,
' Prefix ' => ',
' Encoding ' => ' UTF8 ',
It seems that the database configuration corresponds to the filename under the Cakephp-2.3.5\lib\cake\model\datasource\database directory

(8) test cake, can connect to the database, it means that the work is normal.


The construction of the IIS+YII framework:

IIS supports the configuration of PHP in the previous instructions. Download Yii 1.1.13, extract to D:\sjg\yii-1.1.13.e9e4a0, run a command prompt cmd.exe and switch working directory to D:\sjg\ YII-1.1.13.E9E4A0, run Yiic.bat to create a command line environment for YII (you need to make sure that Php.exe is already in the environment variable path), and then create a web App with Yiic WebApp D:\sjg\myproject

In the IIS configuration, configure the site root directory to D:\sjg\myproject or create a virtual directory MyProject point to D:\sjg\myproject, and configure the site root or virtual directory to parse the. php file (see previous)

In the customer browser input, it is found that the browser anonymous client process needs to have write permissions on some directories, in the following directory, add iuser_***** user's write Modify permission:

/protected/runtime (the directory below will generate the application's run log)


Try again and find that the basic system works.

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.