While PHP can be installed from source, it is also available through packages on Alpine Linux and derivatives that use the apk package manager.
Les versions provenant de tiers sont considérées comme non officielles et ne sont pas directement prises en charge par le projet PHP. Tout bogue rencontré doit être signalé au fournisseur de ces versions non officielles, sauf s'il peut être reproduit à l'aide des versions provenant de » la zone de téléchargement officielle.
The packages can be installed using the apk package manager.
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.
Exemple #1 Alpine Install Example
# 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:
Exemple #2 Enabling and starting PHP-FPM
# apk add php83-fpm # rc-update add php-fpm83 default # rc-service php-fpm83 start
Only the core extensions are installed with the base package. Additional extensions such as MySQL, cURL, GD, etc. can be installed as separate packages.
Exemple #3 Searching for available PHP packages
# apk search php83
The list of packages includes the CLI, FPM, and many extensions. When extensions are installed, their dependencies are automatically resolved.
Exemple #4 Install PHP with MySQL, GD
# apk add php83-mysqli php83-gd
Extensions are automatically enabled when installed; no manual php.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.