--- license: other tags: - php - php-extension - mongodb - mssql - sqlsrv - pdo_sqlsrv - offline - air-gapped pretty_name: PHP MongoDB & MSSQL Extension Binaries + Offline Runtime (Windows + Linux) --- # PHP MongoDB & MSSQL Extensions — Offline Bundle (Windows + Linux) A **self-contained, air-gap-ready** bundle of prebuilt PHP extension binaries for **MongoDB** and **Microsoft SQL Server** (`sqlsrv` + `pdo_sqlsrv`), **plus every runtime dependency** normally downloaded from the internet at install time. Designed to be copied into an **isolated network with no internet access**. Covers **PHP 7.4, 8.0, 8.1, 8.2, 8.3, 8.4** on **Windows (x64 + x86)** and **Linux (x86_64)**. > **Clarifications on the original request** > - There is **no "PHP 7.46"** — PHP 7.x ended at 7.4.33. This bundle targets **PHP ≥ 7.4**. > - On **Windows** PHP extensions are `.dll` (`php_mongodb.dll`, `php_sqlsrv.dll`, `php_pdo_sqlsrv.dll`); > `.so` files are **Linux-only**. Both are provided, correctly per-OS. --- ## What's in the box | Component | Windows | Linux | |-----------|---------|-------| | **mongodb** extension | ✅ 7.4–8.4, x64+x86, TS+NTS | ✅ 7.4–8.4 (RHEL 9 + Debian 12) | | **sqlsrv** extension | ✅ 7.4–8.4, x64+x86, TS+NTS | ✅ 7.4–8.4 (RHEL 9) | | **pdo_sqlsrv** extension | ✅ 7.4–8.4, x64+x86, TS+NTS | ✅ 7.4–8.4 (RHEL 9) | | **MS ODBC Driver** (MSSQL runtime dep) | ✅ v17 + v18, x64+x86 (MSI) | ✅ v17 + v18 (Debian `.deb` + RHEL `.rpm`) | | **Visual C++ Redistributable** (DLL runtime dep) | ✅ x64 + x86 | n/a | **109 files, ~156 MB.** Every binary is listed with a SHA-256 in [`SHA256SUMS`](SHA256SUMS). --- ## Directory layout ``` windows/php///php_mongodb.dll /php_sqlsrv.dll /php_pdo_sqlsrv.dll linux/rhel9/php/x64/mongodb.so # RHEL/Rocky/Alma/CentOS 9 (complete: all 3 exts) /sqlsrv.so /pdo_sqlsrv.so linux/debian12/php/x64/mongodb.so # Debian 12 / Ubuntu (mongodb only) runtime/windows/ msodbcsql18_x64.msi msodbcsql18_x86.msi msodbcsql17_x64.msi msodbcsql17_x86.msi VC_redist.x64.exe VC_redist.x86.exe runtime/linux/debian12/ msodbcsql18_*.deb msodbcsql17_*.deb runtime/linux/rhel9/ msodbcsql18-*.rpm msodbcsql17-*.rpm SHA256SUMS LINUX-MSSQL-BUILD.md # fallback: build sqlsrv/pdo_sqlsrv on other distros ``` `ts` = Thread-Safe (Apache mod_php); `nts` = Non-Thread-Safe (php-fpm / FastCGI / CLI — the usual pick). Check yours: `php -i | grep "Thread Safety"` (Linux) or `php -i | findstr "Thread"` (Windows). --- ## Offline install ### Windows 1. **Install the VC++ redistributable once per machine** (required for the DLLs to load): run `runtime/windows/VC_redist.x64.exe` (and/or the x86 one for 32-bit PHP). 2. **For MSSQL only** — install the ODBC driver: `msiexec /i runtime\windows\msodbcsql18_x64.msi IACCEPTMSODBCSQLLICENSETERMS=YES` (v18 recommended; v17 also included). 3. Match your PHP build (`php -i` → *PHP Version*, *Thread Safety*, *Architecture*) and copy the DLL(s) from `windows/php///` into your PHP `ext\` directory. 4. Enable in `php.ini`: ```ini extension=php_mongodb.dll extension=php_sqlsrv.dll extension=php_pdo_sqlsrv.dll ``` 5. Restart the web server / PHP-FPM; verify with `php -m`. ### Linux — RHEL / Rocky / Alma / CentOS 9 1. **For MSSQL only** — install the ODBC driver (offline): ```bash sudo ACCEPT_EULA=Y rpm -i runtime/linux/rhel9/msodbcsql18-*.rpm # requires unixODBC from your base OS media/repo: sudo dnf install unixODBC ``` 2. Copy the `.so` for your PHP version to the extension dir (`php-config --extension-dir`, e.g. `/usr/lib64/php/modules/`): ```bash sudo cp linux/rhel9/php8.3/x64/{mongodb.so,sqlsrv.so,pdo_sqlsrv.so} $(php-config --extension-dir)/ ``` 3. Enable via `.ini` files in your PHP `conf.d`: ```ini extension=mongodb.so extension=sqlsrv.so extension=pdo_sqlsrv.so ``` 4. `php -m | grep -Ei 'mongodb|sqlsrv'` to verify. ### Linux — Debian 12 / Ubuntu - **mongodb** is provided under `linux/debian12/php/x64/mongodb.so` — copy it to your extension dir (`php -i | grep extension_dir`) and add `extension=mongodb.so`. - **MSSQL:** install the ODBC driver from `runtime/linux/debian12/msodbcsql18_*.deb` (`sudo ACCEPT_EULA=Y dpkg -i ...`; needs `unixodbc` from base repo). Prebuilt `sqlsrv.so` / `pdo_sqlsrv.so` for Debian are **not** in this bundle (Microsoft ships them as source only) — either reuse the RHEL 9 `.so` if your glibc is compatible, or compile them with [`LINUX-MSSQL-BUILD.md`](LINUX-MSSQL-BUILD.md) on a connected build box and copy the result in. --- ## ⚠️ Important notes - **glibc only.** All Linux `.so` are glibc builds — they will **not** run on **musl** distros (Alpine). On Alpine use `apk add php-mongodb` / build against musl. - **PHP minor must match exactly.** A `php8.2` `.so`/`.dll` only loads in PHP 8.2. - **Base-OS dependency:** the MSSQL extensions require **unixODBC** (Linux) — a standard base-repo package — in addition to the Microsoft ODBC driver included here. It's usually already installed. - **Mixing distros:** the RHEL 9 and Debian 12 `.so` are ABI-compatible for the same PHP minor on most modern glibc systems, but for production prefer the set matching your actual distro. ## Version summary | PHP | Win mongodb | Win sqlsrv/pdo | Linux mongodb (rhel9 / deb12) | Linux sqlsrv/pdo (rhel9) | |-----|-------------|----------------|-------------------------------|--------------------------| | 7.4 | 1.20.1 | 5.10.0 | 1.20.1 / 1.20.1 | 5.10.1 | | 8.0 | 1.20.1 | 5.10.0 | 1.20.1 / 1.20.1 | 5.11.1 | | 8.1 | 2.4.1 | 5.12.0 | 2.4.1 / 2.1.4 | 5.12.0 | | 8.2 | 2.4.1 | 5.12.0 | 2.4.1 / 2.1.4 | 5.12.0 | | 8.3 | 2.4.1 | 5.13.3 | 2.4.1 / 2.1.4 | 5.13.3 | | 8.4 | 2.4.1 | 5.13.3 | 2.4.1 / 2.1.4 | 5.13.3 | ODBC driver: v18.6.2.1 + v17 (17.10.6.1 Win / 17.11.1.1 Linux). VC++ Redist: VS2015–2022 (17.x). ## Sources & provenance (all unmodified upstream) - **Windows DLLs:** official PECL — https://downloads.php.net/~windows/pecl/releases/ - **Linux mongodb.so (Debian 12):** https://packages.sury.org/ (deb.sury.org) - **Linux .so (RHEL 9):** Remi's RPM repository — https://rpms.remirepo.net/enterprise/9/ - **MS ODBC Driver & Linux packages:** https://packages.microsoft.com / download.microsoft.com - **VC++ Redistributable:** https://aka.ms/vs/17/release/ Verify integrity with `sha256sum -c SHA256SUMS` (Linux) or `CertUtil -hashfile SHA256` (Windows). ## Licenses - MongoDB PHP extension — **Apache-2.0** - Microsoft Drivers for PHP for SQL Server (`sqlsrv`, `pdo_sqlsrv`) — **MIT** - Microsoft ODBC Driver & Visual C++ Redistributable — **Microsoft EULA** (redistributed for offline convenience; by installing you accept Microsoft's license terms). All trademarks belong to their respective owners. This repo is an unofficial convenience mirror.