Install PHP ODBC in Ubuntu

only support ubuntu 18.04 20.04 22.04

sudo apt update
sudo apt install gnupg

sudo curl https://packages.microsoft.com/keys/microsoft.asc | apt-key add -
sudo curl https://packages.microsoft.com/config/ubuntu/$(lsb_release -rs)/prod.list > /etc/apt/sources.list.d/mssql-release.list
sudo apt update
sudo ACCEPT_EULA=Y apt-get install -y msodbcsql18
sudo ACCEPT_EULA=Y apt-get install -y mssql-tools18
echo 'export PATH="$PATH:/opt/mssql-tools18/bin"' >> ~/.bashrc
source ~/.bashrc
sudo apt-get install -y unixodbc-dev
sudo apt install php-odbc
sudo service apache2 restart
cat /etc/odbcinst.ini
configure driver name specified in odbcinst above

#example
$odbc = odbc_connect('DRIVER={ODBC Driver 18 for SQL Server};SERVER=<server>;DATABASE=<db>;TrustServerCertificate=yes', 'sa', '<password>');

sqlcmd -S host -U user -P pass -C

Note: TrustServerCertificate is required, else it will get ssl error

https://learn.microsoft.com/en-us/sql/connect/odbc/linux-mac/installing-the-microsoft-odbc-driver-for-sql-server?view=sql-server-ver16&tabs=ubuntu18-install%2Calpine17-install%2Cdebian8-install%2Credhat7-13-install%2Crhel7-offline