Install php sqlsrv Ubuntu 20

Berikut cara mengintall paket php-sqlsrv di ubuntu 20

Install terlebih dahulu paket php yang dibutuhkan

sudo su
add-apt-repository ppa:ondrej/php -y
apt-get update
apt-get install php7.4 php7.4-dev php7.4-xml -y --allow-unauthenticated
sudo su
curl | apt-key add -

#Download appropriate package for the OS version
#Choose only ONE of the following, corresponding to your OS version

#Ubuntu 16.04
curl > /etc/apt/sources.list.d/mssql-release.list

#Ubuntu 18.04
curl > /etc/apt/sources.list.d/mssql-release.list

#Ubuntu 20.04
curl > /etc/apt/sources.list.d/mssql-release.list

sudo apt-get update
sudo ACCEPT_EULA=Y apt-get install msodbcsql17
# optional: for bcp and sqlcmd
sudo ACCEPT_EULA=Y apt-get install mssql-tools
echo 'export PATH="$PATH:/opt/mssql-tools/bin"' >> ~/.bash_profile
echo 'export PATH="$PATH:/opt/mssql-tools/bin"' >> ~/.bashrc
source ~/.bashrc
# optional: for unixODBC development headers
sudo apt-get install unixodbc-dev

source :

Setelah paket diatas terinstall, berikutnya install paket sqlsrv nya...

sudo pecl install sqlsrv
sudo pecl install pdo_sqlsrv
sudo su
printf "; priority=20\\n" > /etc/php/7.4/mods-available/sqlsrv.ini
printf "; priority=30\\n" > /etc/php/7.4/mods-available/pdo_sqlsrv.ini
sudo phpenmod -v 7.4 sqlsrv pdo_sqlsrv

Restart apache2

Posted on: September 26, 2020, by :