Skip to content

IBM i (AS/400) Access ODBC for PHP 8 on Ubuntu/Debian — step-by-step guide + PDO example + Docker/Compose templates.

License

Notifications You must be signed in to change notification settings

elightsys/iSeries-Access-ODBC-Driver-for-PHP

Repository files navigation

IBM i (AS/400) Access ODBC Driver for PHP 8 on Ubuntu/Debian

License Last commit PRs Welcome Stars

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.


Tested Matrix

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.


TL;DR

# 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.

Detailed Setup

1) Install ODBC components

sudo apt-get update
sudo apt-get install -y unixodbc odbcinst

2) Install IBM i Access ODBC

Obtain 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-*.rpm

Do not commit IBM installers to this repository.

3) Create a DSN

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=1208

Security: For system DSN, restrict file permissions:

sudo chmod 600 /etc/odbc.ini

4) PHP integration

Prefer 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;

Minimal Docker/Compose

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-stopped

Place a minimal test page under public/:

<?php
phpinfo(); // confirm ODBC/PDO_ODBC listed

And 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.


Troubleshooting

  • Check ODBC installation

    odbcinst -j
    isql -v MYIBMI
  • PHP can’t find ODBC
    Ensure pdo_odbc is enabled. In Dockerfile we run docker-php-ext-install pdo_odbc. On host, verify with:

    php -m | grep -i odbc

    and check phpinfo().

  • Driver path / lib64 issues
    Some systems require a lib64 symlink for IBM libraries. Verify the actual installed paths and add symlinks if needed.

  • Permissions
    If /etc/odbc.ini is world-readable, credentials are exposed. Use chmod 600.


Security Notes

  • Do not commit secrets or IBM installers into the repository.
  • Restrict DSN files (chmod 600).
  • Prefer environment variables or secret managers in production.

Roadmap

  • More OS/PHP matrix entries
  • GitHub Actions for docs lint + link check
  • Community troubleshooting additions

Contributing

See CONTRIBUTING.md. PRs welcome!

License

Copyright © 2025 Zoltan Vlasits. Licensed under MIT

About

IBM i (AS/400) Access ODBC for PHP 8 on Ubuntu/Debian — step-by-step guide + PDO example + Docker/Compose templates.

Topics

Resources

License

Contributing

Stars

Watchers

Forks

Packages

No packages published