How to install PHP Extension for MSSQL

Hi,

Does anyone know how to install PHP Extension for MSSQL / SQL SERVER?

I need to connect to a remote MSSQL server database to fetch some data for my PHP application.

I’m using CentOS 8 and CyberPanel version 2.1.

Any help would be much appreciated.

Thank you!

In cyberpanel go to the PHP->PHP extension and install any extension that you need for any version.

Thank you, Sir. The problem is I cannot find the extension for the SQL server.

Do you know any other way to install this? Thank you

PHP: Installation - Manual.

For lsphp74 please try below command :

cd /usr/local/lsws/lsphp74/bin
./pecl install pdo_sqlsrv

Report when success :

Build process completed successfully
Installing '/usr/local/lsws/lsphp74/lib64/php/modules/pdo_sqlsrv.so'
install ok: channel://pecl.php.net/pdo_sqlsrv-5.10.1
configuration option "php_ini" is not set to php.ini location
You should add "extension=pdo_sqlsrv.so" to php.ini

Before execute above command, please make sure extension lsphp74-pear already installed

i have tried this… but im getting:

-lodbcinst
libtool: link: cc -shared -fPIC -DPIC .libs/conn.o .libs/util.o .libs/init.o .libs/stmt.o shared/.libs/core_conn.o shared/.libs/core_results.o shared/.libs/core_stream.o shared/.libs/core_init.o shared/.libs/core_stmt.o shared/.libs/core_util.o shared/.libs/FormattedPrint.o shared/.libs/localizationimpl.o shared/.libs/StringFunctions.o -lstdc++ /usr/lib64/libodbc.so /usr/lib64/libodbcinst.so -lltdl -lrt -lpthread -g -O2 -Wl,-z -Wl,now -pthread -Wl,-soname -Wl,sqlsrv.so -o .libs/sqlsrv.so
/usr/bin/ld: cannot find -lltdl
collect2: error: ld returned 1 exit status
make: *** [Makefile:250: sqlsrv.la] Error 1
ERROR: `make’ failed

O erro “/usr/bin/ld: cannot find -lltdl” ocorre porque o linker (ld) não consegue encontrar a biblioteca “libltdl” durante o processo de compilação e vinculação do módulo pdo_sqlsrv. Para resolver esse problema, você pode seguir os seguintes passos:

Instalar a biblioteca "libltdl":
No CentOS 8, você pode instalar a biblioteca "libltdl" usando o comando abaixo:
sudo dnf install libtool-ltdl-devel

  • Este pacote contém os arquivos de desenvolvimento da biblioteca “libltdl” necessários para a compilação do módulo.
  • Tente instalar o módulo pdo_sqlsrv novamente: Após a instalação do pacote “libtool-ltdl-devel”, tente instalar o módulo pdo_sqlsrv novamente e veja se o erro foi resolvido.