You may need to run pecl channel-update first. The following instructions install PHP 8.0 by default using pecl install, if the PHP 8.0 packages are available. For an explanation of extension loading and why we do not add the extensions to php.ini, see the section on loading the drivers. These instructions advise installing the drivers using PECL, but you can also download the prebuilt binaries from the Microsoft Drivers for PHP for SQL Server GitHub project page and install them following the instructions in Loading the Microsoft Drivers for PHP for SQL Server.
The following instructions assume a clean environment and show how to install PHP 8.0, the Microsoft ODBC driver, the Apache web server, and the Microsoft Drivers for PHP for SQL Server on Ubuntu, Red Hat, Debian, Suse, Alpine, and macOS.