CentOS 5.4 Linux 上の
PHP (FastCGI) は、関連部門の SQL Server 2000 データベースに接続する必要があり、拡張された FreeTDS 拡張機能で構成されています。
1. FreeTDS をコンパイルしてインストールします
<ol class="dp-xml"> <li class="alt"><span><span>mkdir -p /data0/software/ </span></span></li> <li><span>cd /data0/software/ </span></li> <li class="alt"><span>wget ftp://ftp.ibiblio.org/pub/Linux/ALPHA/freetds/stable/freetds-stable.tgz </span></li> <li><span>tar zxvf freetds-stable.tgz </span></li> <li class="alt"><span>cd freetds-0.82/ </span></li> <li> <span>./configure </span><span class="attribute">--prefix</span><span>=/usr/local/webserver/freetds </span><span class="attribute">--with-tdsver</span><span>=</span><span class="attribute-value">8</span><span>.0 --enable-msdblib </span> </li> <li class="alt"><span>make && make install </span></li> <li><span>cd ../ </span></li> <li class="alt"><span> </span></li> <li> <span>echo "/usr/local/webserver/freetds/lib/" </span><span class="tag">></span><span> /etc/ld.so.conf.d/freetds.conf </span> </li> <li class="alt"><span>ln -s /usr/local/webserver/freetds/lib/libsybdb.so.5.0.0 /usr/local/webserver/freetds/lib/libsybdb.so.4 </span></li> <li><span>/sbin/ldconfig </span></li> <li class="alt"><span> </span></li> <li><span>rm -f /usr/local/webserver/freetds/etc/freetds.conf </span></li> <li class="alt"><span>vi /usr/local/webserver/freetds/etc/freetds.conf </span></li> </ol>
次の内容を入力します:
Quote
<ol class="dp-xml"> <li class="alt"><span><span>[global] </span></span></li> <li><span> # TDS protocol version </span></li> <li class="alt"> <span>; tds </span><span class="attribute">version</span><span> = </span><span class="attribute-value">4</span><span>.2 </span> </li> <li><span> </span></li> <li class="alt"><span> # Whether to write a TDSDUMP file for diagnostic purposes </span></li> <li><span> # (setting this to /tmp is insecure on a multi-user system) </span></li> <li class="alt"> <span>; dump </span><span class="attribute">file</span><span> = /tmp/freetds.log </span> </li> <li> <span>; debug </span><span class="attribute">flags</span><span> = </span><span class="attribute-value">0xffff</span><span> </span> </li> <li class="alt"><span> </span></li> <li><span> # Command and connection timeouts </span></li> <li class="alt"> <span>; </span><span class="attribute">timeout</span><span> = </span><span class="attribute-value">10</span><span> </span> </li> <li> <span>; connect </span><span class="attribute">timeout</span><span> = </span><span class="attribute-value">10</span><span> </span> </li> <li class="alt"><span> </span></li> <li><span> # If you get out-of-memory errors, it may mean that your client </span></li> <li class="alt"><span> # is trying to allocate a huge buffer for a TEXT field. </span></li> <li><span> # Try setting 'text size' to a more reasonable limit </span></li> <li class="alt"> <span> text </span><span class="attribute">size</span><span> = </span><span class="attribute-value">64512</span><span> </span> </li> <li><span> </span></li> <li class="alt"> <span> </span><span class="attribute">host</span><span> = </span><span class="attribute-value">mssql</span><span>.yourdomain.com </span> </li> <li> <span> </span><span class="attribute">port</span><span> = </span><span class="attribute-value">1433</span><span> </span> </li> <li class="alt"> <span> tds </span><span class="attribute">version</span><span> = </span><span class="attribute-value">8</span><span>.0 </span> </li> <li> <span> client </span><span class="attribute">charset</span><span> = </span><span class="attribute-value">UTF</span><span>-8 </span> </li> </ol>
2. PHP 独自の MSSQL 拡張機能をコンパイルしてインストールします
ローカルの既存の php-5.2.XX ソース コード パッケージ ディレクトリを入力します:
<ol class="dp-xml"> <li class="alt"><span><span>cd /data0/software/php-5.2.XX/ext/mssql/ </span></span></li> <li><span>/usr/local/webserver/php/bin/phpize </span></li> <li class="alt"> <span>./configure </span><span class="attribute">--with-php-config</span><span>=/usr/local/webserver/php/bin/php-config </span><span class="attribute">--with-mssql</span><span>=/usr/local/webserver/freetds/ </span> </li> <li><span>make && make install </span></li> </ol>
3. mssql.so
<ol class="dp-xml"><li class="alt"><span><span>vi /usr/local/webserver/php/etc/php.ini </span></span></li></ol>
をphp.ini設定ファイルに追加します:
Quote
<ol class="dp-xml"><li class="alt"><span><span class="attribute">extension</span><span> = </span><span class="attribute-value">"mssql.so"</span><span> </span></span></li></ol>
4. PHP FastCGI
<ol class="dp-xml"><li class="alt"><span><span>/usr/local/webserver/php/sbin/php-fpm restart </span></span></li></ol>
を再起動します。 5. テストファイル(test_mssql.php):
www.bkjia.com