大网数据广告活动
PHP 语言与运行手册

Installing from packages on Alpine Linux

· 52CE 我爱测

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

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.

Warning

Builds from third-parties are considered unofficial and not directly supported by the PHP project. Any bugs encountered should be reported to the provider of those unofficial builds unless they can be reproduced using the builds from » the official download area.

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.

Example #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:

Example #2 Enabling and starting PHP-FPM

# 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 MySQL, cURL, GD, etc. can be installed as separate packages.

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

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

来源:PHP Documentation Group · 作者与贡献记录 · CC BY 3.0。离线整理了版式、链接和媒体显示。

资料来源与适用范围

资料来源
PHP Documentation Group
适用范围
请按文中版本与环境说明核对
内容语言
中文;命令、路径和错误标识保留技术原文
本地收录日期
2026-11-15
授权说明
CC BY 3.0

正文与所需资源由本站本地存储。查看来源及更新记录 ↗

请按适用版本和实际日志确认原因;本站没有对每一种系统或设备逐项执行文中的操作。