독까의 이야기

필요한 파일 준비

Fast CGI Extension 설치
fcgisetup_1.5_rtw_x86.msi

 http://www.iis.net/downloads/microsoft/fastcgi-for-iis

 fcgisetup_1.5_rtw_x86.msi

 

 VC6 x86 Non Thread Safe

php-5.2.4-nts-Win32.zip
http://museum.php.net/php5/

php-5.2.4-nts-Win32.zip

 

SQLSRV20.EXE
https://www.microsoft.com/en-us/download/details.aspx?id=20098

SQLSRV20.EXE

 

 

MS-SQL Native Client 10
sqlncli.msi
http://www.microsoft.com/en-us/download/confirmation.aspx?id=16978

sqlncl.msi

 

 

기본 설정 php.ini

5.2.4_php.ini

 

 

[ 적용 방법 ]

 

  -  php 설치 및 ms-sql 연동
     ->  Windows 2003 에 설치 가능한 php 버전 확인 : 
          5.4.X 까지는 설치 가능
          단, php 와 ms-sql 연동 가능은 5.3.0 까지 가능 / 그 이상은 ms-sql 과 연동이 되지 않음 : https://msdn.microsoft.com/en-us/library/cc296170(v=sql.105).aspx
          php 5.2.x 이상부터는 ms-sql.dll 을 지원하지 않음 / sqlsrv_x_.dll 을 추가해서 연동 시켜야 함
          sql 과 연결하기 위한 SQL NativeClient 설치 및 시스템 DSN 등록 필요

     ->  Fast CGI Extension 설치 : fcgisetup_1.5_rtw_x86.msi (http://www.iis.net/downloads/microsoft/fastcgi-for-iis)

     ->  php-5.2.4-nts-Win32.zip 다운로드 : http://museum.php.net/php5/
          폴더 생성 및 압축 해제: c:\php
          폴더 권한 설정 : 권한 추가 - Network Service : 읽기 및 실행

     ->  SQL 연동을 위한 확장 dll 설치 : SQLSRV20.EXE (https://www.microsoft.com/en-us/download/details.aspx?id=20098)
          경로 : c:\php\ext

     ->  MS-SQL Native Client 설치 : sqlncli.msi (http://www.microsoft.com/en-us/download/confirmation.aspx?id=16978)
          Windows 2003 은 Native Client 10 까지만 설치 가능 / 11 이상은 설치가 되지 않음 

     ->  IIS 설정변경
          IIS - 웹사이트 - 우클릭 - 속성 - 홈 디렉터리 - 구성 - 추가
          실행 파일 : C:\WINDOWS\system32\inetsrv\fcgiext.dll
          확장명 : .php
          다음으로 제한 : GET, HEAD, POST

     ->  fastcgi.ini 수정
          C:\WINDOWS\system32\inetsrv\fcgiext.ini
          최하단에 아래 내용 추가 후 저장
          [Types]
          php=PHP
          inc=PHP
          html=PHP
          [PHP]
          ExePath=C:\php\php-cgi.exe          

     ->  php.ini 수정
          c:\php.ini-recommended 를 선택하여 파일 이름을 php.ini 로 변경하고 내용 수정 및 주석 제거
          fastcgi.impersonate = 1
          cgi.fix_pathinfo = 1
          cgi.force_redirect = 0
          short_open_tag = On
          allow_url_fopen = Off
          default_charset = "UTF-8"
          date.timezone = "Asia/Seoul"
          display_errors = On
          
          extension= 모듈 이 나열되어 있는 곳에 추가
          extension=php_sqlsrv_52_nts.dll
          extension=php_pdo_sqlsrv_52_nts.dll

     ->  IIS 재시작 

     ->  phpinfo.php 파일 생성 : 
          <?
          phpinfo();
          ?>

     ->  도메인/phpinfo.php 

     ->  phpinfo 정상 출력 확인

     ->  db 연동 테스트 진행
          odbc 데이터 원본 관리자 실행 - 시스템 DSN - SQL Native Client 10
          이름 : test / 서버 : DB 서버 아이피
          SQL 서버 인증 : DB 아이디 / DB 패스워드
          접속 테스트 성공

     ->  php + mssql 연결 테스트 페이지 작성
          <?php 
             $serverName = "DB 서버 아이피"; 
             $connectionInfo = array ("Database"=>"DB명","UID"=>"DB 아이디","PWD"=>"DB 패스워드"); 
             $conn = sqlsrv_connect($serverName, $connectionInfo); 
                   if ($conn) 
                  { 
                    echo "연결 성공!\n"; 
                  } 
                   else 
                  {
                   echo "연결 실패!\n"; 
                  die ( print_r (sqlsrv_errors(), true)); 
                   } 
                   sqlsrv_close($conn); 
          ?> 

     ->  도메인/db_test.php 
     ->  "연결 성공!" 문구 출력 확인 

MS 기술문서 페이지에서 긁어옴

 

System Requirements (Microsoft Drivers for PHP for SQL Server)

 

To access data in a SQL Server 2005 or later database using the Microsoft Drivers for PHP for SQL Server (SQL Server 2008 or later if using version 3.2 or 3.1), you must have the following components installed on your computer:

  • Supported operating systems for version 3.2 and 3.1 of the driver include:

    • Windows Server 2008 R2 SP1

    • Windows Vista SP2

    • Windows Server 2008 SP2

    • Windows 7 SP1

    • Windows Server 2012

    • Windows Server 2012 R2

    • Windows 8

    • Windows 8.1

  • Supported operating systems for version 3.0 of the driver include:

    • Windows Server 2008 R2 SP1

    • Windows Vista SP2

    • Windows Server 2008 SP2

    • Windows 7 SP1

  • Supported operating systems for version 2.0 of the driver include:

    • Supported operating systems for version 2.0 of the driver include:

    • Windows Server 2003 Service Pack 1

    • Windows XP Service Pack 3

    • Windows Vista Service Pack 1 or later

    • Windows Server 2008

    • Windows Server 2008 R2

    • Windows 7

  • SQL Azure Databases are supported. For information see Connecting to Windows Azure SQL Database.

  • PHP 5.x is required. For information about how to download and install the latest stable binaries, seehttp://php.net.

  • Microsoft Drivers for PHP for SQL Server, versions require PHP versions in the following table:

Microsoft Drivers for PHP for SQL Server Version

Supported PHP Versions

3.2

PHP 5.6.4+ or

PHP 5.5.16+ or

PHP 5.4.32

3.1

PHP 5.5.16+ or

PHP 5.4.32

3.0

PHP 5.4.32 or

PHP 5.3.0

2.0

PHP 5.3.0 or

PHP 5.2.4 or

PHP 5.2.13

  • A version of the driver file must be in your PHP extension directory. See Driver Versions later in this topic for information about the different driver files. See Loading the Microsoft Drivers for PHP for SQL Server for information on configuring the driver for the PHP runtime. To download the drivers, see Microsoft Drivers for PHP for SQL Server.

  • A Web server is required. Your Web server must be configured to run PHP. For information about hosting PHP applications with Internet Information Services (IIS) 6.0, see Using FastCGI to Host PHP Applications on IIS 6.0. For information about hosting PHP applications with IIS 7.0, see Using FastCGI to Host PHP Applications on IIS 7.0.

    The Microsoft Drivers for PHP for SQL Server has been tested using IIS 6 and IIS 7 with FastCGI.

    System_CAPS_noteNote

    Microsoft provides support only for IIS.

  • Versions 3.2 and 3.1 require Microsoft ODBC Driver 11 (or higher) for SQL Server. To download the Microsoft ODBC Driver 11 for PHP for SQL Server, see Microsoft ODBC Driver 11 for SQL Server.

    If you are using the SQLSRV driver, sqlsrv_client_info will return information about which version of SQL Server Native Client is being used by the Microsoft Drivers for PHP for SQL Server. If you are using the PDO_SQLSRV driver, you can use PDO::getAttribute to discover the version.

  • For versions 3.0 and 2.0, the x86 version of SQL Server Native Client is required on the computer where PHP is running. If you are using a 64-bit operating system, the x86 version of SQL Server Native Client will be installed with the x64 version of SQL Server Native Client (do not install the x86 version of SQL Server Native Client on an x64 operating system).

    If you are using the SQLSRV driver, sqlsrv_client_info will return information about which version of SQL Server Native Client is being used by the Microsoft Drivers for PHP for SQL Server. If you are using the PDO_SQLSRV driver, you can use PDO::getAttribute to discover the version.

This section lists the drivers that are included with versions 3.2, 3.1, 3.0, and 2.0 of the Microsoft Drivers for PHP for SQL Server.

Follow the installation instructions in Loading the Driver to configure the driver for use with the PHP runtime.

Microsoft Drivers 3.2 for PHP for SQL Server installs the following versions of the driver:

Driver file

PHP version

Thread safe?

Use with PHP .dll

php_sqlsrv_54_nts.dll

php_pdo_sqlsrv_54_nts.dll

5.4

no

php5.dll

php_sqlsrv_54_ts.dll

php_pdo_sqlsrv_54_ts.dll

5.4

yes

php5ts.dll

php_sqlsrv_55_nts.dll

php_pdo_sqlsrv_55_nts.dll

5.5

no

php5.dll

php_sqlsrv_55_ts.dll

php_pdo_sqlsrv_55_ts.dll

5.5

yes

php5ts.dll

php_sqlsrv_56_nts.dll

php_pdo_sqlsrv_56_nts.dll

5.6

no

php5.dll

php_sqlsrv_56_ts.dll

php_pdo_sqlsrv_56_ts.dll

5.6

yes

php5ts.dll

Microsoft Drivers 3.1 for PHP for SQL Server installs the following versions of the driver:

Driver file

PHP version

Thread safe?

Use with PHP .dll

php_sqlsrv_54_nts.dll

php_pdo_sqlsrv_54_nts.dll

5.4

no

php5.dll

php_sqlsrv_54_ts.dll

php_pdo_sqlsrv_54_ts.dll

5.4

yes

php5ts.dll

php_sqlsrv_55_nts.dll

php_pdo_sqlsrv_55_nts.dll

5.5

no

php5.dll

php_sqlsrv_55_ts.dll

php_pdo_sqlsrv_55_ts.dll

5.5

yes

php5ts.dll

Microsoft Drivers 3.0 for PHP for SQL Server installs the following versions of the driver:

Driver file

PHP version

Thread safe?

Use with PHP .dll

php_sqlsrv_53_nts.dll

php_pdo_sqlsrv_53_nts.dll

5.3

no

php5.dll

php_sqlsrv_53_ts.dll

php_pdo_sqlsrv_53_ts.dll

5.3

yes

php5ts.dll

php_sqlsrv_54_nts.dll

php_pdo_sqlsrv_54_nts.dll

5.4

no

php5.dll

php_sqlsrv_54_ts.dll

php_pdo_sqlsrv_54_ts.dll

5.4

yes

php5ts.dll

Microsoft Drivers 2.0 for PHP for SQL Server installs the following versions of the driver:

Driver file

PHP version

Thread safe?

Use with PHP .dll

php_sqlsrv_53_nts_vc6.dll

php_pdo_sqlsrv_53_nts_vc6.dll

5.3

no

php5.dll

php_sqlsrv_53_nts_vc9.dll

php_pdo_sqlsrv_53_nts_vc9.dll

5.3

no

php5.dll

php_sqlsrv_53_ts_vc6.dll

php_pdo_sqlsrv_53_ts_vc6.dll

5.3

yes

php5ts.dll

php_sqlsrv_53_ts_vc9.dll

php_pdo_sqlsrv_53_ts_vc9.dll

5.3

yes

php5ts.dll

php_sqlsrv_52_nts_vc6.dll

php_pdo_sqlsrv_52_nts_vc6.dll

5.2

no

php5.dll

php_sqlsrv_52_ts_vc6.dll

php_pdo_sqlsrv_52_ts_vc6.dll

5.2

yes

php5ts.dll

If the name of the driver file contains "vc9", it should be used with a PHP version compiled with Visual C++ 9.0.

1.  OS 시스템 변동 사항 확인 

 

C:\> systeminfo

 

2.  사용자 계정 변동 사항 확인

 

C:\> net user 계정명