Category: Debian Ubuntu
Created: 2015-05-26
Updated: 2020-12-18
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 9 | Debian 10 | Ubuntu 16 | Ubuntu 18 | Ubuntu 20 |
---|---|---|---|---|
PHP 4.4.9 | ||||
PHP 5.3.29 | ||||
PHP 5.4.45 | ||||
PHP 5.5.38 | ||||
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.3.x | PHP 7.3.x | PHP 7.3.x | PHP 7.3.x | PHP 7.3.x |
PHP 7.4.x | PHP 7.4.x | PHP 7.4.x | PHP 7.4.x | PHP 7.4.x |
PHP 8.0.x | PHP 8.0.x | PHP 8.0.x | PHP 8.0.x | PHP 8.0.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 9 (“Stretch”):
deb http://repo.liveconfig.com/debian/ stretch php
Debian 10 (“Buster”):
deb http://repo.liveconfig.com/debian/ buster php
Ubuntu 16.04 LTS (“Xenial Xerus”):
deb http://repo.liveconfig.com/debian/ xenial 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
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 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.