Skip to content

Instantly share code, notes, and snippets.

Show Gist options
  • Save programmerShinobi/18353b0038514473e74e6c73e8891fb5 to your computer and use it in GitHub Desktop.
Save programmerShinobi/18353b0038514473e74e6c73e8891fb5 to your computer and use it in GitHub Desktop.
Setup PHP 8.1 with sqlsrv & pdo_sqlsrv on Linux (Ubuntu 22.04)
faqih@shinobi:~$ sudo apt-get update
faqih@shinobi:~$ sudo apt-get upgrade
faqih@shinobi:~$ sudo service packagekit restart
faqih@shinobi:~$ sudo apt-get update --fix-missing
faqih@shinobi:~$ sudo apt install lsb-release ca-certificates apt-transport-https software-properties-common -y
faqih@shinobi:~$ sudo add-apt-repository ppa:ondrej/php
faqih@shinobi:~$ sudo apt update
faqih@shinobi:~$ sudo dpkg --configure -a
faqih@shinobi:~$ sudo apt --fix-broken install
faqih@shinobi:~$ sudo apt update
faqih@shinobi:~$ sudo apt-get install php8.1 php8.1-fpm
faqih@shinobi:~$ sudo apt-get install php8.1-mysql php8.1-mbstring php8.1-xml php8.1-gd php8.1-curl
faqih@shinobi:~$ php -v
SHOW (install success) :
PHP 8.1.25 (cli) (built: Oct 27 2023 14:00:40) (NTS)
Copyright (c) The PHP Group
Zend Engine v4.1.25, Copyright (c) Zend Technologies
with Zend OPcache v8.1.25, Copyright (c), by Zend Technologies
faqih@shinobi:~$ sudo apt-get update
faqih@shinobi:~$ sudo apt-get -y --no-install-recommends install apt-utils libxml2-dev gnupg apt-transport-https
faqih@shinobi:~$ sudo apt-get clean
faqih@shinobi:~$ sudo rm -rf /var/lib/apt/lists/* /tmp/* /var/tmp/* /usr/share/doc/*
faqih@shinobi:~$ sudo apt-get clean
faqih@shinobi:~$ sudo apt update
faqih@shinobi:~$ sudo apt install asc
faqih@shinobi:~$ sudo service packagekit restart
faqih@shinobi:~$ sudo apt-get update --fix-missing
faqih@shinobi:~$ sudo apt install php8.1-dev
faqih@shinobi:~$ sudo apt-get install libtool
faqih@shinobi:~$ curl https://packages.microsoft.com/keys/microsoft.asc | gpg --dearmor > microsoft.gpg
faqih@shinobi:~$ sudo mv microsoft.gpg /etc/apt/trusted.gpg.d/microsoft.gpg
faqih@shinobi:~$ sudo apt-get update
faqih@shinobi:~$ ACCEPT_EULA=Y sudo apt-get -y --no-install-recommends install msodbcsql17
faqih@shinobi:~$ sudo pecl install sqlsrv-5.11.1
faqih@shinobi:~$ sudo sh -c 'echo "extension=sqlsrv.so" >> $(php --ini | grep "Scan for additional .ini files" | sed -e "s|.*:\s*||")/30-sqlsrv.ini'
faqih@shinobi:~$ sudo pecl install pdo_sqlsrv-5.11.1
faqih@shinobi:~$ sudo sh -c 'echo "extension=pdo_sqlsrv.so" >> $(php --ini | grep "Scan for additional .ini files" | sed -e "s|.*:\s*||")/30-pdo_sqlsrv.ini'
faqih@shinobi:~$ php -S localhost:8080
SHOW (install success) :
[Fri Nov 24 16:53:11 2023] PHP 8.1.25 Development Server (http://localhost:8080) started
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment