1

I cannot figure out the way to connect MSSQL 2014 database on centos 8 using PhP 7.4. I found GitHub link and downloaded CentOS8-7.4.tar and extracted the php_sqlsrv_72_ts.so and php_pdo_sqlsrv_72_ts.so. but not sure where to paste the modules like

windows => xampp folder > php >> extensions

edit php.ini; extension=php_sqlsrv_72_ts and restart web server

Any help or guidance is really appreciated. Here are the commands I did run:

dnf -y update
dnf install yum-utils http://rpms.remirepo.net/enterprise/remi-release-8.rpm -y
dnf module reset php
dnf module enable php:remi-7.4
yum module reset nginx
yum module enable nginx:1.16
dnf install wget nginx php-fpm mariadb-server php-mysqli php-gd php-imap php-xml php-mbstring php-intl php-pecl-apcu php-opcache php-pecl-zip
systemctl enable --now nginx php-fpm mariadb
firewall-cmd --permanent --zone=public --add-service=http --add-service=https
firewall-cmd --reload

PHP:

<?php

    $serverName = "ServerIP\Instance";
    $connectionInfo = array( "Database"=>"dummydatabase", "UID"=>"sa", "PWD"=>"mystrongpasswrod",'ReturnDatesAsStrings'=> true);
    $conn = sqlsrv_connect( $serverName, $connectionInfo );
    if( $conn === false ) {
      die( print_r( sqlsrv_errors(), true));
    }
    else{
      echo 'Successfully Connected';
    }

1 Answer 1

0

GOT IT, run the commands below:

dnf install php-pear php-devel unixODBC-devel make

pecl install sqlsrv pdo_sqlsrv

#https://packages.microsoft.com/rhel/8/prod/
dnf -y install https://packages.microsoft.com/rhel/8/prod/msodbcsql17-17.6.1.1-1.x86_64.rpm

echo 'extension=pdo_sqlsrv.so' > /etc/php.d/30-pdo_sqlsrv.ini

echo 'extension=sqlsrv.so' > /etc/php.d/30-sqlsrv.ini

setsebool -P httpd_can_network_connect_db 1
1
  • Can you clarify if this is for the client connecting to your MSSQL server, or for the MSSQL server itself, to allow remote connections? Commented Apr 14, 2021 at 20:33

You must log in to answer this question.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.