There are no notfications.

This article was last reviewed for Debian 9 (Stretch).

PHP 5 configuration environment (Debian, repository)

PHP 5 configuration environment (Debian, repository)
Author: Stefán Örvar Sigmundsson
Initial publication:
Last updated:
Written in: English (United Kingdom)

PHP is the world's most popular server-side web development scripting language. The original and primary PHP interpreter implementation is the Zend Engine. This article will demonstrate how to use the configuration environment of PHP 5 on Debian or its derivatives such as Ubuntu and Linux Mint.

Environment

The Debian php5 package sets up a particular directory layout. The Zend Engine itself does not require that the layout be used but the helper scripts that come with the package do. It is therefore recommended that the layout be used.

Directory layout

The following table summarises the directory layout:

PHP 5 configuration environment directory layout
Path Purpose Debian package
/etc/php5/ PHP configuration directory. php5-common
/etc/php5/apache/ Configuration directory for the Apache mod_php5 SAPI. libapache2-mod-php5[1]
/etc/php5/cgi/ Configuration directory for the CGI SAPI. php5-cgi[1]
/etc/php5/cli/ Configuration directory for the CLI SAPI. php5-cli[2]
/etc/php5/fpm/ Configuration directory for the PHP-FPM SAPI. php5-fpm[1]
/etc/php5/mods-available/ Loadable extension directory. php5-common
  1. ^ a b c Depends on php5-common and php5-cli.
  2. ^ Depends on php5-common.

apache

The apache directory contains PHP configuration for when the Apache module mod_php5 is used to control the Zend Engine. mod_php5 has been largely deprecated in favour of PHP-FPM.

conf.d
See § fpm
php.ini
See § fpm

cgi

The cgi directory contains PHP configuration for when CGI is used to run PHP scripts. CGI has been largely deprecated in favour of PHP-FPM.

conf.d
See § fpm
php.ini
See § fpm

cli

The cli directory contains PHP configuration for when the command-line interpreter (/usr/bin/php5) is used to run PHP scripts. CLI is largely used for testing PHP scripts via the terminal emulator.

conf.d
See § fpm
php.ini
See § fpm

fpm

The fpm directory contains PHP configuration for when the FastCGI process manager PHP-FPM is used to control the Zend Engine.

conf.d
The conf.d directory contains symbolic links to files in the mods-available directory. The files in the mods-available directory enable loadable extensions to be used by the PHP SAPI. This allows for the loadable extensions to be turned on and off without having to modify the php.ini file since PHP SAPIs are compiled to include files from their respective conf.d directory and not the mods-available directory.
pool.d
The pool.d directory contains configuration files for process pools managed by PHP-FPM.
php.ini
The php.ini file contains PHP's configuration.
php-fpm.conf
The php-fpm.conf file contains PHP-FPM's configuration.

mods-available

The mods-available directory contains files that dynamically load extensions. To enable loadable extensions, symbolic links are created in conf.d which point to files in mods-available. This allows for the loadable extensions to be turned on and off without having to modify the php.ini file since PHP SAPIs are compiled to include files from their respective conf.d directory and not the mods-available directory.

Helper scripts

The Debian php5-common package comes with 2 helper scripts that automate enablement and disablement of loadable extensions for all SAPIs.

php5enmod

To enable the loadable extensions json, opcache and pdo for all SAPIs:

root@computer:~# php5enmod json opcache pdo

php5dismod

To disable the loadable extensions json, opcache and pdo for all SAPIs:

root@computer:~# php5dismod json opcache pdo

See also

External links