记-php连接mssql遇上的问题

  (1) This extension requires the Microsoft SQL Server 2012 Native Client. Access the following URL to download the Microsoft SQL Server 2012 Native Client ODBC driver for x86: http://go.microsoft.com/fwlink/?LinkId=163712

  根据提示信息进入到: http://go.microsoft.com/fwlink/?LinkId=163712页面,在根据你的服务器所属操作系统,里面有完整的操作步骤说明;

  下面是linux(redhat)下来进行的操作设置:

    

Installing the drivers on Red Hat 7

[!NOTE] To install PHP 7.1 or 7.2, replace remi-php73 with remi-php71 or remi-php72 respectively in the following commands.

Step 1. Install PHP

sudo su
wget https://dl.fedoraproject.org/pub/epel/epel-release-latest-7.noarch.rpm
wget https://rpms.remirepo.net/enterprise/remi-release-7.rpm
rpm -Uvh remi-release-7.rpm epel-release-latest-7.noarch.rpm
subscription-manager repos --enable=rhel-7-server-optional-rpms
yum install yum-utils
yum-config-manager --enable remi-php73
yum update
yum install php php-pdo php-xml php-pear php-devel re2c gcc-c++ gcc

Step 2. Install prerequisites

Install the ODBC driver for Red Hat 7 by following the instructions on the Linux and macOS installation page.

Compiling the PHP drivers with PECL with PHP 7.2 or 7.3 requires a more recent GCC than the default:

sudo yum-config-manager --enable rhel-server-rhscl-7-rpms
sudo yum install devtoolset-7
scl enable devtoolset-7 bash

Step 3. Install the PHP drivers for Microsoft SQL Server

sudo pecl install sqlsrv
sudo pecl install pdo_sqlsrv
sudo su
echo extension=pdo_sqlsrv.so >> `php --ini | grep "Scan for additional .ini files" | sed -e "s|.*:\s*||"`/30-pdo_sqlsrv.ini
echo extension=sqlsrv.so >> `php --ini | grep "Scan for additional .ini files" | sed -e "s|.*:\s*||"`/20-sqlsrv.ini
exit

An issue in PECL may prevent correct installation of the latest version of the drivers even if you have upgraded GCC. To install, download the packages and compile manually (similar steps for pdo_sqlsrv):

pecl download sqlsrv
tar xvzf sqlsrv-5.6.0.tgz
cd sqlsrv-5.6.0/
phpize
./configure --with-php-config=/usr/bin/php-config
make
sudo make install

You can alternatively download the prebuilt binaries from the Github project page, or install from the Remi repo:

sudo yum install php-sqlsrv

Step 4. Install Apache

sudo yum install httpd

SELinux is installed by default and runs in Enforcing mode. To allow Apache to connect to databases through SELinux, run the following command:

sudo setsebool -P httpd_can_network_connect_db 1

Step 5. Restart Apache and test the sample script

sudo apachectl restart

To test your installation, see Testing your installation at the end of this document.

  (2)A network-related or instance-specific error occurred while establishing a connection to SQL Server. The server was not found or was not

     accessible. Verify that the instance name is correct and that SQL Server is configured to allow remote connections. (provider: Named Pipes

    Provider, error: 40 - Could not open a connection to SQL Server)

    这是mssql连接过程中,连接mssql ip地址不通

  (3)code:08001

    

    

猜你喜欢

转载自www.cnblogs.com/leonchan/p/11301425.html