PHP Snippet 1:
sudo a2dismod php7.3
sudo a2enmod php7.4
sudo service apache2 restart
PHP Snippet 2:
<?php
print_r(PDO::getAvailableDrivers());
?>
PHP Snippet 3:
leo@alpha:~$ php PDO.php
PHP Snippet 4:
Array
(
[0] => mysql
[1] => pgsql
[2] => sqlsrv
)
PHP Snippet 5:
DB_CONNECTION=sqlsrv
DB_HOST=localhost
DB_PORT=1433
DB_DATABASE=project
DB_USERNAME=sa
DB_PASSWORD=password
PHP Snippet 6:
<?php
php_info();
?>
PHP Snippet 7:
sudo apt update
sudo apt install -y lsb-release ca-certificates apt-transport-https software-properties-common
echo "deb https://packages.sury.org/php/ $(lsb_release -sc) main" | sudo tee /etc/apt/sources.list.d/sury-php.list
wget -qO - https://packages.sury.org/php/apt.gpg | sudo apt-key add -
sudo apt update
PHP Snippet 8:
sudo apt install php7.2 php7.4 php8.0
PHP Snippet 9:
sudo apt install phpx.x-{mysql,cli,common,imap,ldap,xml,fpm,curl,mbstring,zip}
PHP Snippet 10:
sudo update-alternatives --set php /usr/bin/php7.2
sudo update-alternatives --set phar /usr/bin/phar7.2
sudo update-alternatives --set phar.phar /usr/bin/phar.phar7.2
sudo update-alternatives --set phpize /usr/bin/phpize7.2
sudo update-alternatives --set php-config /usr/bin/php-config7.2
sudo apt install php7.2-dev
sudo pecl config-set php_ini /etc/php/7.2/fpm/php.ini
sudo pecl config-set ext_dir /usr/lib/php/20170718/
sudo pecl -d php_sufix=7.2 install sqlsrv
sudo pecl -d php_sufix=7.2 install pdo_sqlsrv
sudo su
printf "; priority=20\nextension=sqlsrv.so\n" > /etc/php/7.2/mods-available/sqlsrv.ini
printf "; priority=30\nextension=pdo_sqlsrv.so\n" > /etc/php/7.2/mods-available/pdo_sqlsrv.ini
exit
sudo phpenmod -s fpm -v 7.2 sqlsrv pdo_sqlsrv
sudo phpenmod -s apache2 -v 7.2 sqlsrv pdo_sqlsrv
sudo phpenmod -s cli -v 7.2 sqlsrv pdo_sqlsrv
sudo service php7.2-fpm restart
sudo service apache2 restart
PHP Snippet 11:
sudo update-alternatives --set php /usr/bin/php7.4
sudo update-alternatives --set phar /usr/bin/phar7.4
sudo update-alternatives --set phar.phar /usr/bin/phar.phar7.4
sudo update-alternatives --set phpize /usr/bin/phpize7.4
sudo update-alternatives --set php-config /usr/bin/php-config7.4
sudo apt install php7.4-dev
sudo pecl config-set php_ini /etc/php/7.4/fpm/php.ini
sudo pecl config-set ext_dir /usr/lib/php/20190902
sudo pecl -d php_sufix=7.4 install sqlsrv
sudo pecl -d php_sufix=7.4 install pdo_sqlsrv
sudo su
printf "; priority=20\nextension=sqlsrv.so\n" > /etc/php/7.4/mods-available/sqlsrv.ini
printf "; priority=30\nextension=pdo_sqlsrv.so\n" > /etc/php/7.4/mods-available/pdo_sqlsrv.ini
exit
sudo phpenmod -s fpm -v 7.4 sqlsrv pdo_sqlsrv
sudo phpenmod -s apache2 -v 7.4 sqlsrv pdo_sqlsrv
sudo phpenmod -s cli -v 7.4 sqlsrv pdo_sqlsrv
sudo service php7.4-fpm restart
sudo service apache2 restart
PHP Snippet 12:
sudo update-alternatives --set php /usr/bin/php8.0
sudo update-alternatives --set phar /usr/bin/phar8.0
sudo update-alternatives --set phar.phar /usr/bin/phar.phar8.0
sudo update-alternatives --set phpize /usr/bin/phpize8.0
sudo update-alternatives --set php-config /usr/bin/php-config8.0
sudo apt install php8.0-dev
sudo pecl config-set php_ini /etc/php/8.0/fpm/php.ini
sudo pecl config-set ext_dir /usr/lib/php/20200930
sudo pecl -d php_sufix=8.0 install sqlsrv
sudo pecl -d php_sufix=8.0 install pdo_sqlsrv
sudo su
printf "; priority=20\nextension=sqlsrv.so\n" > /etc/php/8.0/mods-available/sqlsrv.ini
printf "; priority=30\nextension=pdo_sqlsrv.so\n" > /etc/php/8.0/mods-available/pdo_sqlsrv.ini
exit
sudo phpenmod -s fpm -v 8.0 sqlsrv pdo_sqlsrv
sudo phpenmod -s apache2 -v 8.0 sqlsrv pdo_sqlsrv
sudo phpenmod -s cli -v 8.0 sqlsrv pdo_sqlsrv
sudo service php8.0-fpm restart
sudo service apache2 restart
PHP Snippet 14:
php -m | grep sqlsrv
PHP Snippet 15:
sudo pecl -d php_sufix=7.2 uninstall sqlsrv
sudo pecl -d php_sufix=7.2 uninstall pdo_sqlsrv
sudo pecl -d php_sufix=7.4 uninstall sqlsrv
sudo pecl -d php_sufix=7.4 uninstall pdo_sqlsrv
sudo pecl -d php_sufix=8.0 uninstall sqlsrv
sudo pecl -d php_sufix=8.0 uninstall pdo_sqlsrv