Step-by-step guide to configure IBM i (AS/400) Access ODBC with PHP 8 on Ubuntu/Debian, plus a PDO example and minimal Docker/Compose templates.
Heads-up: IBM i Access ODBC packages are license-protected. This repo explains the steps but does not redistribute IBM packages. Please obtain them per IBM's terms.
| Component | Versions |
|---|---|
| PHP | 8.1 / 8.2 |
| OS | Ubuntu 20.04 / 22.04, Debian 12 |
| Web | Apache (php:8.2-apache base) |
| ODBC | unixODBC / IBM i Access ODBC Driver |
Contributions for additional versions are welcome via PRs.
# System deps
sudo apt-get update && sudo apt-get install -y unixodbc odbcinst
# Install IBM i Access ODBC driver (obtain package from IBM; do NOT commit it here).
# e.g. using alien if you received an RPM:
# sudo apt-get install -y alien
# sudo alien -i iSeriesAccess-*.rpm
# Configure DSN
sudo nano /etc/odbc.ini # or use ~/.odbc.ini
sudo chmod 600 /etc/odbc.ini
# Verify ODBC
odbcinst -j
isql -v MYIBMI
# PHP PDO ODBC extension
# In Docker we run docker-php-ext-install pdo_odbc; on host use distro packages or rebuild PHP.sudo apt-get update
sudo apt-get install -y unixodbc odbcinstObtain the IBM i Access ODBC package from IBM (download portal or vendor). Follow your license terms. If you have an RPM on Debian/Ubuntu:
sudo apt-get install -y alien
sudo alien -i iSeriesAccess-*.rpmDo not commit IBM installers to this repository.
Create /etc/odbc.ini (system DSN) or ~/.odbc.ini (user DSN). Example:
[MYIBMI]
Description=IBM i Access ODBC Driver (Example DSN)
Driver=IBM i Access ODBC Driver
System=YOUR_IBMI_HOST_OR_IP
UserID=YOUR_USERNAME
Password=YOUR_PASSWORD
Naming=1
DefaultLibraries=YOURLIB
Database=YOURDB
CCSID=1208Security: For system DSN, restrict file permissions:
sudo chmod 600 /etc/odbc.iniPrefer PDO ODBC for modern code:
<?php
$pdo = new PDO('odbc:DSN=MYIBMI', 'YOUR_USERNAME', 'YOUR_PASSWORD', [
PDO::ATTR_ERRMODE => PDO::ERRMODE_EXCEPTION,
PDO::ATTR_DEFAULT_FETCH_MODE => PDO::FETCH_ASSOC,
]);Run a sanity query (replace table/db as needed):
SELECT CURRENT_DATE as today FROM SYSIBM.SYSDUMMY1;Dockerfile:
FROM php:8.2-apache
RUN apt-get update && apt-get install -y --no-install-recommends unixodbc odbcinst alien wget ca-certificates && rm -rf /var/lib/apt/lists/*
RUN docker-php-ext-install pdo_odbc
COPY odbc.ini /etc/odbc.ini
COPY public/ /var/www/html/docker-compose.yml:
version: "3.9"
services:
php:
build: .
ports:
- "8080:80"
volumes:
- ./public:/var/www/html
- ./odbc.ini:/etc/odbc.ini:ro
restart: unless-stoppedPlace a minimal test page under public/:
<?php
phpinfo(); // confirm ODBC/PDO_ODBC listedAnd a PDO test (public/test_pdo.php) that queries SYSIBM.SYSDUMMY1.
Note: This image does not include IBM packages. Add them in your build process if your license allows, or install at runtime on the host.
-
Check ODBC installation
odbcinst -j isql -v MYIBMI
-
PHP can’t find ODBC
Ensurepdo_odbcis enabled. In Dockerfile we rundocker-php-ext-install pdo_odbc. On host, verify with:php -m | grep -i odbcand check
phpinfo(). -
Driver path / lib64 issues
Some systems require alib64symlink for IBM libraries. Verify the actual installed paths and add symlinks if needed. -
Permissions
If/etc/odbc.iniis world-readable, credentials are exposed. Usechmod 600.
- Do not commit secrets or IBM installers into the repository.
- Restrict DSN files (
chmod 600). - Prefer environment variables or secret managers in production.
- More OS/PHP matrix entries
- GitHub Actions for docs lint + link check
- Community troubleshooting additions
See CONTRIBUTING.md. PRs welcome!
Copyright © 2025 Zoltan Vlasits. Licensed under MIT