Translation(s): none
PHP on Debian
Contents
PHP is a popular general-purpose scripting language that is especially suited to web development.
Essential information for users and packagers of PHP on Debian. For more detailed documentation, see the Further information section.
Installation
To install PHP’s CLI and common files (documentation, examples, common modules and utilities):
apt install php-cli
PHP version by Debian release
Debian Release
PHP Version
7.3
7.0
Managing extensions
You can add functionality by adding extensions, or disable specific extensions.
See the installed extensions:
php -m
Enable an extension:
phpenmod [extension]
Disable an extension:
phpdismod [extension]
Example: phpdismod php-zip disables the PHP Zip extension.
Find available extensions:
apt search php-
Configuration system
For each PHP version M.N (e.g., 7.4, 8.2), the configuration files are organized as follows:
Main configuration: /etc/php/M.N/$SAPI/php.ini Additional configurations: /etc/php/M.N/$SAPI/conf.d/
Where $SAPI is the Server API (apache2/cgi/fpm/cli/phpdbg/etc.). The compile-time option specifies:
--with-config-file-scan-dir=/etc/php/M.N/$SAPI/conf.d
Any file in this directory ending in .ini will be loaded by PHP. The environment variable PHP_INI_SCAN_DIR can override the compile-time path.
Package naming conventions
For each PHP version M.N, a metapackage php requires the default phpM.N package, which includes at least one PHP server engine (libapache2-mod-php7.0, php7.0-fpm, etc.).
To see all PHP-related packages:
apt search php
For PHP developers and packagers
Packaging PHP applications
Packagers should consult the PHP draft policy. For support, subscribe to the debian-webapps@lists.debian.org mailing list.
Extension development
Extensions should install configurations to /etc/php/M.N/mods-available Use /usr/lib/php/php-maintscript-helper to enable extensions The dh-php package provides helpers for packaging PECL extensions
Contributing to PHP in Debian
To help with PHP maintenance in Debian:
Contact the pkg-php-maint@lists.alioth.debian.org mailing list See the PHP Group Team page
Security considerations
Read sudo cat /usr/share/doc/php*/README.Debian.security for detailed security information.
The Debian PHP maintainers prioritize security issues by:
Highest priority: Remote code execution vulnerabilities (buffer overflows, code inclusion) Medium priority: Other remotely exploitable issues Low priority: Issues requiring unsafe application usage Ignored: Issues in deprecated features (safe mode, register globals) and those requiring local access
Multiple PHP versions using 3rd party repository
The Sury repository allows installation of multiple PHP versions simultaneously (5.6 through 8.4) on a single system. This repository is NOT part of the official Debian repositories.
It's a reputable repository used by professionals, but use at your own risk!
Each version installs with separate binaries, configuration files and PHP modules.For detailed instructions, see AdditionalPHPVersions.
Further information
/usr/share/doc/php* - Local documentation
Debian PHP maintainer's list: pkg-php-maint@lists.alioth.debian.org (Browse the list)
Debian webapps mailing list: debian-webapps@lists.debian.org (Browse the list)