Category: Debian Ubuntu
Created: 2015-05-26
Updated: 2024-04-15
If several PHP versions are available on a server, LiveConfig allows the selection of the PHP version per subdomain.
The following instructions show how to install additional PHP versions under Debian or Ubuntu Linux and register them in LiveConfig.
LiveConfig provides a number of ready-to-use PHP packages for all current Debian and Ubuntu versions. The available versions are:
Debian 10 | Debian 11 | Debian 12 | Ubuntu 18 | Ubuntu 20 | Ubuntu 22 |
---|---|---|---|---|---|
PHP 5.6.40 | PHP 5.6.40 | PHP 5.6.40 | PHP 5.6.40 | PHP 5.6.40 | PHP 5.6.40 |
PHP 7.0.33 | PHP 7.0.33 | PHP 7.0.33 | PHP 7.0.33 | ||
PHP 7.1.33 | PHP 7.1.33 | PHP 7.1.33 | PHP 7.1.33 | ||
PHP 7.2.34 | PHP 7.2.34 | PHP 7.2.34 | PHP 7.2.34 | PHP 7.2.34 | PHP 7.2.34 |
PHP 7.3.33 | PHP 7.3.33 | PHP 7.3.33 | PHP 7.3.33 | PHP 7.3.33 | PHP 7.3.33 |
PHP 7.4.33 | PHP 7.4.33 | PHP 7.4.33 | PHP 7.4.33 | PHP 7.4.33 | PHP 7.4.33 |
PHP 8.0.30 | PHP 8.0.30 | PHP 8.0.30 | PHP 8.0.30 | PHP 8.0.30 | PHP 8.0.30 |
PHP 8.1.x | PHP 8.1.x | PHP 8.1.x | PHP 8.1.x | PHP 8.1.x | PHP 8.1.x |
PHP 8.2.x | PHP 8.2.x | PHP 8.2.x | PHP 8.2.x | PHP 8.2.x | PHP 8.2.x |
PHP 8.3.x | PHP 8.3.x | PHP 8.3.x | PHP 8.3.x | PHP 8.3.x | PHP 8.3.x |
The numbers ending with “.x” always refer to the most current version (these are still actively maintained by PHP).
To use the LiveConfig PHP repository, edit the file /etc/apt/sources.list.d/liveconfig.list
and add the following line (depending on your Linux distribution):
Debian 10 (“Buster”):
deb http://repo.liveconfig.com/debian/ buster php
Debian 11 (“Bullseye”):
deb http://repo.liveconfig.com/debian/ bullseye php
Debian 12 (“Bookworm”):
deb http://repo.liveconfig.com/debian/ bookworm php
Ubuntu 18.04 LTS (“Bionic Beaver”):
deb http://repo.liveconfig.com/debian/ bionic php
Ubuntu 20.04 LTS (“Focal Fossa”):
deb http://repo.liveconfig.com/debian/ focal php
Ubuntu 22.04 LTS (“Jammy Jellyfish”):
deb http://repo.liveconfig.com/debian/ jammy php
Afterwards update the repository data:
apt update
Then you can install the desired PHP version, e.g.:
apt install php-7.3-opt
All PHP packages provided by LiveConfig are named php-
+ version + -opt
. To find all available extensions e.g. for PHP 7.3, run the following command:
apt search php-7.3-opt
Only if you have installed PHP manually or from another repository: for each additional version, create a corresponding Lua file in /etc/liveconfig/lua.d/
. For example for PHP 7.3, name that file php73.lua
.
The LiveConfig PHP packages for PHP 5.6 and later already contain such a file, you can skip this step in this case.
-- register additional PHP interpreter with LiveConfig
LC.web.addPHP( {
['id'] = 'php73',
['cli'] = '/opt/php-7.3/bin/php',
['cgi'] = '/opt/php-7.3/bin/php-cgi',
['fpm'] = {
['bin'] = '/opt/php-7.3/sbin/php-fpm',
['start'] = 'service php73-fpm start',
['stop'] = 'service php73-fpm stop',
['reload'] = 'service php73-fpm reload',
['pool'] = '/etc/php-fpm/php73-fpm.d',
['sockets'] = '/var/run/php73-fpm'
}
} )
Alternatively to creating a file in /etc/liveconfig/lua.d/
you may register PHP with a simlified call to LC.web.addPHP()
in the file /usr/lib/liveconfig/lua/custom.lua
- but this method is deprecated and should not be used any more:
LC.web.addPHP("php55", "/opt/php-5.5/bin/php-cgi")
LC.web.addPHP("php56", "/opt/php-5.6/bin/php-cgi")
Run liveconfig --diag
(or on a client system: lcclient --diag
) and watch the PHP section:
root@srv:~# liveconfig --diag
[...]
- PHP 7.3.20 (code='php73', eol='2021-12-06')
CGI/FastCGI: /opt/php-7.3/bin/php-cgi
FPM: /opt/php-7.3/sbin/php-fpm
pool config: /etc/php-fpm/php73-fpm.d
default php.ini: '/opt/php-7.3/etc/php.ini'
[...]
Only if you have installed PHP manually or from another repository: restart LiveConfig (systemctl restart liveconfig
) to enable the new PHP interpreter(s).
LiveConfig uses the PHP version provided by the respective Linux distribution as “default version”.
If you want to use a different PHP interpreter as the standard version, create a file /etc/liveconfig/lua.d/php-default.lua
and enter the following line there:
-- change PHP default version
LC.web.PHPDEFAULT = 'php73'
Instead of php73
please enter the code of the desired PHP version (see listing when running liveconfig --diag
).
If you run liveconfig --diag
again, the selected version should then be marked with [DEFAULT]
. Restart LiveConfig to apply the changes.
For the PHP versions 5.6 to 7.4 and 8.1 we also provide ready-to-run packages of the ionCube loader. The packages are named php-x.y-opt-ioncube
. Just install the package using apt (e.g. apt install php-7.4-opt-ioncube
), the ionCube loader will automatically be registered in the respective php.ini.
The best way to delete outdated PHP versions is as follows:
In LiveConfig go to Server Management -> Web. In the box PHP versions you can see the available PHP versions on the server and how many subdomains they are used by.
To switch off the use step by step, you can set the restricted option from LiveConfig 2.11 - the affected PHP version can then still to be used with the subdomains configured in this way, but can no longer be selected for new configurations / subdomains.
If a PHP version is ultimately no longer used (number of subdomains in the Usage column = 0), then delete the corresponding PHP interpreter from the server, e.g.:
apt purge php-5.6-opt
Then check in LiveConfig that the PHP version you just deleted no longer appears in the list of available PHP versions. Old PHP packages or packages not provided by LiveConfig may have to be removed manually from custom.lua
, and LiveConfig or lcclient may have to be restarted on the affected server.
Finally, you can delete the configuration files that are no longer required from the server, e.g.:
root@srv:~# cd /var/www
root@srv:/var/www# chattr -R -i web*/conf/php56
root@srv:/var/www# rm -rf web*/conf/php56