php8.5
Home/ Manual/ install / unix/ Installing from packages on Alpine Linux

Installing from packages on Alpine Linux

While PHP can be installed from source, it is also available through packages on Alpine Linux and derivatives that use the apk package manager.

While PHP can be installed from source, it is also available through packages on Alpine Linux and derivatives that use the apk package manager.

Third-party-support

The packages can be installed using the apk package manager.

Installing packages

PHP packages in Alpine Linux include the major version number in their name (e.g. php83 for PHP 8.3). In the examples below, replace 83 with the PHP version available on your Alpine Linux release.

Before installing a package, ensure the package index is up to date by running apk update.

Alpine Install Example

shell
# apk add php83

Alpine does not configure PHP for a web server automatically. For FastCGI setups, install php83-fpm and enable the php-fpm83 OpenRC service (note that the package name and the service name use different ordering of the version suffix). For example:

Enabling and starting PHP-FPM

shell
# apk add php83-fpm
# rc-update add php-fpm83 default
# rc-service php-fpm83 start

Better control of configuration

Only the core extensions are installed with the base package. Additional extensions such as

can be installed as separate packages.

Searching for available PHP packages

shell
# apk search php83

The list of packages includes the CLI, FPM, and many extensions. When extensions are installed, their dependencies are automatically resolved.

Install PHP with MySQL, GD

shell
# apk add php83-mysqli php83-gd

Extensions are automatically enabled when installed; no manual Ini editing is required. Configuration files are placed in /etc/php83/conf.d/. After installing new extensions, PHP-FPM (or the web server) needs to be restarted for the changes to take effect.

Source: install/unix/alpine.xml · from the official PHP manual (php/doc-en)