Installing the Chilkat PHP Extension on Linux and Alpine Linux

Installing the Chilkat extension on Linux (x86_64, x86, arm64, armv7l) and Alpine Linux — with one command, in a Dockerfile, or step by step — plus the checks that prevent the common “unable to load” errors.

Quick install — one command

Using Composer (any OS) — the package holds the PHP classes, and its installer fetches the matching extension:

composer require chilkat/chilkat
vendor/bin/chilkat-install

Without Composer — Linux and Alpine Linux (run as root, or with sudo as shown):

curl -fsSL https://chilkatdownload.com/php/install-php.sh | sudo sh

The script asks your PHP which version, architecture, and thread-safety it is, downloads the matching build, installs chilkat.so/chilkat.dll and chilkat.php, enables the extension, and runs a test. If you prefer to do it by hand, the steps below are exactly what the script automates.

Options: --dry-run shows what would be done, --php /path/to/php targets a specific PHP (e.g. the one PHP-FPM uses), --uninstall removes it again; add options after sh -s --, e.g. curl -fsSL https://chilkatdownload.com/php/install-php.sh | sudo sh -s -- --dry-run.

Docker, Alpine Linux, and CI

Containers are where most Alpine (and much Linux) PHP runs, and there the whole install is one Dockerfile line. The official php images (Alpine or Debian; cli, fpm, apache) ship curl, build as root, and read $PHP_INI_DIR/conf.d for every SAPI, which is exactly what the install script needs:

FROM php:8.3-fpm-alpine
RUN curl -fsSL https://chilkatdownload.com/php/install-php.sh | sh

The script detects the image's PHP (version, CPU, thread-safety, musl or glibc), installs the matching chilkat.so, drops chilkat.ini into conf.d, and verifies the load. On Alpine it also adds the libstdc++ package, which the minimal php:*-alpine images do not ship and chilkat.so needs. Pin the Chilkat version for reproducible builds: … | sh -s -- --version 11.6.1.

With Composer, the package supplies the classes and its installer fetches the extension:

FROM php:8.3-cli-alpine
COPY --from=composer:2 /usr/bin/composer /usr/bin/composer
WORKDIR /app
COPY . .
RUN composer install --no-dev --no-interaction && vendor/bin/chilkat-install

In a multi-stage build, run the installer in the final stage — the one whose PHP serves the application. A ten-second smoke test of any image:

docker run --rm php:8.3-cli-alpine sh -c "curl -fsSL https://chilkatdownload.com/php/install-php.sh | sh >/dev/null && php -m | grep chilkat"

GitHub Actions and similar CI runners: PHP from shivammathur/setup-php keeps its extension_dir root-owned, so run the installer with sudo (hosted runners allow it without a password):

- uses: shivammathur/setup-php@v2
  with:
    php-version: '8.3'
- run: composer install --no-interaction
- run: sudo php vendor/bin/chilkat-install        # or: curl -fsSL https://chilkatdownload.com/php/install-php.sh | sudo sh
Installing by hand on Alpine: use the Alpine download, which is built for musl libc — the standard Linux (glibc) build will not load on Alpine. All other steps are identical.

Installing by hand

The steps below are what the installers automate; use them if you prefer to place the files yourself, or on a system without curl or Composer.

The download must match your PHP build A PHP extension only loads into a PHP that matches it:
  • PHP version — e.g. the 8.5 extension for PHP 8.5.
  • Architecturex86_64, x86, aarch64, or armv7l.
  • Thread safety (ZTS): the ZTS download for a thread-safe PHP, or the regular (non-ZTS) download otherwise.
  • C library: the standard Linux build for glibc systems, the Alpine build for musl. They are not interchangeable.
Step 3 shows how to read these from your PHP.
  1. Download

    Get the build for your system from the Chilkat Linux PHP Downloads (Linux and Alpine are both listed there).

  2. What's in the download

    Each .tar.gz contains:

    chilkat-php-<version>-<arch>-linux/
    ├─ chilkat.so              the Chilkat PHP extension
    ├─ chilkat.php             PHP class definitions (your script includes this)
    ├─ phpinfo.php             prints your PHP configuration
    ├─ showExtDir.php          prints the extension directory
    ├─ test.php                verifies the install
    ├─ license.pdf
    ├─ pcre2-license.pdf
    ├─ quickjs-license.pdf
    └─ THIRD-PARTY-NOTICES.txt
    Two files, two roles: chilkat.so is the native extension that PHP loads (Steps 4–5). chilkat.php defines the Chilkat classes (CkGlobal, CkHttp, …) and is included by your own scripts — keep it where your script can find it (your project directory or a path on include_path).
  3. Check your PHP version, architecture, and thread safety

    php -v
    php -i | grep -E "Thread Safety|Architecture"
    uname -m
    php --ini          # shows the Loaded Configuration File (php.ini)

    If Thread Safety is enabled, use the ZTS download; if disabled, use the regular download. Match the architecture to uname -m.

  4. Copy chilkat.so to the extension directory

    Find the extension directory:

    php showExtDir.php          # prints ini_get("extension_dir")

    Copy the extension there (usually requires root):

    sudo cp chilkat.so "$(php -r 'echo ini_get(\"extension_dir\");')"
  5. Enable the extension in php.ini

    Open the php.ini reported by php --ini, find the Dynamic Extensions section, and add:

    extension=chilkat.so

    If PHP runs under Apache, Nginx, or PHP-FPM, restart that service afterward so the change takes effect. (Note the web SAPI may load a different php.ini than the CLI — check phpinfo() in the web context.)

  6. Verify with test.php

    Run the included test.php, which unlocks Chilkat in trial mode and performs an AES encrypt/decrypt:

    php test.php

    Successful output looks like:

    Unlocked in trial mode.
    4846f83aa211e239aa62a21f527f089ee9ddbead30ee15d4e79b607a621b97bedb9b6f00a9b21f1b43a50b4c1be0edf2
    The quick brown fox jumps over the lazy dog.
  7. Use Chilkat in your scripts

    Include chilkat.php and unlock once at startup (any string starts the 30-day trial; use your license code after purchase):

    <?php
    include("chilkat.php");
    
    $glob = new CkGlobal();
    $glob->UnlockBundle("Anything for 30-day trial");
    
    // ... use any Chilkat class, e.g. new CkHttp(), new CkJsonObject(), ...
    ?>

    See also: Installing the chilkat.php file for all apps.


Common errors

“Unable to load dynamic library 'chilkat.so'”

Usually a mismatch between the extension and your PHP. Re-check Step 3 and confirm the PHP version, architecture, and thread safety (ZTS) all match the download.

A GLIBC version error during load

If you see an error mentioning a required GLIBC_x.xx version, your system's glibc is older than the build expects. Use the Legacy Linux build, which targets a much older glibc. (On Alpine, use the Alpine/musl build instead.)

“Class 'CkGlobal' not found”

Your script didn't include the class definitions. Add include("chilkat.php"); and make sure chilkat.php is reachable from your script (same directory or on the include_path).

Works on the command line but not in the web server

CLI and the web SAPI (Apache module / PHP-FPM) often use different php.ini files. Run phpinfo() in the failing context, edit the Loaded Configuration File it reports, and restart the web service.