Setting up a windows PHP server with MSSQL

本文详细介绍了如何在Windows环境下通过下载并安装Microsoft 2008 C++运行时、Microsoft FastCGI插件、PHP及其SQL Server驱动等组件,实现PHP与MSSQL服务器的连接。

摘要生成于 C知道 ,由 DeepSeek-R1 满血版支持, 前往体验 >

Some of us, maybe a few of us need to setup a PHP webserver on a windows machine. I know you PHP fans are probably disgusted even thinking about PHP on a windows server. Anyways it’s not very easy to setup PHP, but yet it’s not difficult either, you just need to download a bunch of stuff. I setup PHP (without MySQL) on a Windows 2003 Enterprise Server. I needed to access a Microsoft SQL server in my environment so no need for a MySQL server. So this setup describes how to download PHP and the MSSQL extensions to allow you to connect to a remote MSSQL server.

This assumes you’ve already installed IIS for Windows 2003. In this example I’m using x86.

1. First download and install the Microsoft 2008 C++ Runtime. Forx86 click here, and forx64 click here.

2. Download, and install the Microsoft FastCGI addon for IIS make sure it’s allowed in the IIS extensions (IIS Manager > Web  Service Extensions), and restart the WWW publishing service.

3. Download and install PHP for Windows. I chose 5.2 because at the time of this writing MSSQL extensions weren’t compatible with 5.3 yet (of course I found out the hard way after installing 5.3, and ended up downgrading). You can download the VC9 version (assuming you are using IIS and not Apache). It’s up to you if you want to download the thread safe or the non thread safe. The difference can be foundhere. For this example I choose non thread safe.

4. Restart the WWW publishing service.

5. Download Microsoft SQL Server Driver for PHP. Put the php_sqlsrv.dll (or php_sqlsrv_ts.dll if you installed the thread safe version of PHP) in the PHP extensions directory (default location will be C:\Program Files\PHP\ext).

6. Now edit the php.ini file in the PHP directory (default location will be C:\Program Files\PHP), and put the following where all the extensions are located at (near the bottom).

Non thread safe: extension=php_sqlsrv.dll

Thread safe: extension=php_sqlsrv_ts.dll.

7. Download and install the Microsoft SQL Server Native Client since my SQL server is remote (normally this would be already loaded if SQL is on the same machine as this server)

7. Restart the WWW publishing service.

8. Now lets verify that PHP and the MSSQL driver are loaded. Create a info.php file in your wwwroot and put the below code in file and save it. Now visit http://localhost/info.php, and you should see PHP information, including if the MSSQL extension loaded. That’s it. Now if you need to find out how to connect to MSSQL through PHP in code, reference the help file that came with the SQL server driver download.

<?php

phpinfo()

?>

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值