|
Installing from packages on Debian GNU/Linux and related distributionsWhile PHP can be installed from source, it is also available through packages from » Debian GNU/Linux. This is also true for other distributions based on Debian, such as Ubuntu, Kali Linux, and Linux Mint. 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 either the apt or aptitude commands. This manual page uses these two commands interchangeably. Using APT
First, note that other related packages may be desired like
Second, before installing a package, it's wise to ensure the package list is up to date. Typically, this is done by running the command apt update. Example #1 Debian Install Example with Apache 2 # apt install php-common libapache2-mod-php php-cli APT will automatically install the PHP module for Apache 2 and all of its dependencies, and then activate it. Apache should be restarted in order for the changes take place. For example: Example #2 Stopping and starting Apache once PHP is installed # /etc/init.d/apache2 stop # /etc/init.d/apache2 start Better control of configurationIn the last section, PHP was installed with only core modules. It's very likely that additional modules will be desired, such as MySQL, cURL, GD, etc. These may also be installed via the apt command. Example #3 Methods for listing additional PHP packages # apt-cache search php # apt search php | grep -i mysql # aptitude search php
The list of packages will include a large number of packages that includes
basic PHP components, such as Example #4 Install PHP with MySQL, cURL # apt install php-mysql php-curl
APT will automatically add the appropriate lines to the
different php.ini related files like
/etc/php/7.4/php.ini,
/etc/php/7.4/conf.d/*.ini, etc. and depending on
the extension will add entries similar to Common Problems
|