Introduction
When connecting to a Microsoft SQL server, installing pdo_sqlsrv is necessary for PHP to communicate with this third-party SQL service. Several options exist to connect to SQL servers, but utilizing pdo_sqlsrv
is the best option and has few requirements.
Please note that pdo_sqlsrv
requires PHP 8.0 or newer.
Procedure
Please note that this is a task that an administrator should perform to avoid conflicts and issues. Manually attempting to install any package or related functionality may result in a conflict that needs to be addressed by an administrator before a successful installation is achieved.
- Access the server's command line as the 'root' user via SSH or "Terminal" in WHM.
- Install the Microsoft SQL Driver using Microsoft's documentation.
Microsoft Docs: Installing the Microsoft SQL Driver for Linux
- Install the following packages.
- RHEL-based servers
dnf install gcc-c++ libtool-ltdl-devel unixODBC-devel -y
- Ubuntu
apt install g++ libltdl-dev unixodbc-dev -y
- RHEL-based servers
- Install the
sqlsrv
package.
The exec function must not be disabled for the PHP version you are installing this on. If exec is present in the disable_functions setting you will need to remove it using the WHM MultiPHP Manager interface.
/usr/bin/ea-php8#-pecl install sqlsrv
Please note that "#" must be replaced with the PHP subversion for which the package is being installed.
Please note that for PHP 8.0,sqlsrv
must be replaced withsqlsrv-5.11.0
. - Install the
pdo_sqlsrv
PECL package./usr/bin/ea-php8#-pecl install pdo_sqlsrv
Please note that "#" must be replaced with the PHP subversion for which the package is being installed.
Please note that for PHP 8.0,pdo_sqlsrv
must be replaced withpdo_sqlsrv-5.11.0
. -
Finally, you can check that the modules installed successfully with a command like this
/usr/bin/ea-php8# -m | grep sqlsrv
Additional resources
How to add a command or binary to CageFS for all users using addrpm
How to install PHP extensions using PECL using WHM
How To Enable A Particular PHP Extension For A Cloudlinux ALT-PHP## Installation?
Comments
0 comments
Article is closed for comments.