<?php
include_once $_SERVER['DOCUMENT_ROOT'] . '/include/shared-manual.inc';
$TOC = array();
$TOC_DEPRECATED = array();
$PARENTS = array();
include_once dirname(__FILE__) ."/toc/install.unix.inc";
$setup = array (
  'home' => 
  array (
    0 => 'index.php',
    1 => 'PHP Manual',
  ),
  'head' => 
  array (
    0 => 'UTF-8',
    1 => 'it',
  ),
  'this' => 
  array (
    0 => 'install.unix.debian.php',
    1 => 'Installing from packages on Debian GNU/Linux and related distributions',
    2 => 'Installing from packages on Debian GNU/Linux and related distributions',
  ),
  'up' => 
  array (
    0 => 'install.unix.php',
    1 => 'Installazione su sistemi Unix',
  ),
  'prev' => 
  array (
    0 => 'install.unix.php',
    1 => 'Installazione su sistemi Unix',
  ),
  'next' => 
  array (
    0 => 'install.unix.dnf.php',
    1 => 'Installing from packages on GNU/Linux distributions that use DNF',
  ),
  'alternatives' => 
  array (
  ),
  'source' => 
  array (
    'lang' => 'en',
    'path' => 'install/unix/debian.xml',
  ),
  'history' => 
  array (
  ),
);
$setup["toc"] = $TOC;
$setup["toc_deprecated"] = $TOC_DEPRECATED;
$setup["parents"] = $PARENTS;
manual_setup($setup);

contributors($setup);

?>
<div id="install.unix.debian" class="sect1">
 <h2 class="title">Installing from packages on Debian GNU/Linux and related distributions</h2>
 <p class="para">
  While PHP can be installed from source, it is also available through
  packages from <a href="http://www.debian.org/" class="link external">&raquo;&nbsp;Debian GNU/Linux</a>.
  This is also true for other distributions based on Debian, such as
  Ubuntu, Kali Linux, and Linux Mint.
 </p>
 <div class="warning"><strong class="warning">Avviso</strong>
 <p class="para">
  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 <a href="https://www.php.net/downloads.php" class="link external">&raquo;&nbsp;the official download
  area</a>.
 </p>
</div>
 <p class="para">
  The packages can be installed using either the <strong class="command">apt</strong> or
  <strong class="command">aptitude</strong> commands. This manual page uses these two
  commands interchangeably.
 </p>
 <div class="sect2" id="install.unix.debian.apt">
  <h3 class="title">Using APT</h3>
   <p class="simpara">
    First, note that other related packages may be desired like
    <code class="literal">libapache-mod-php</code> to integrate with Apache 2, and
    <code class="literal">php-pear</code> for PEAR.
   </p>
   <p class="simpara">
    Second, before installing a package, it&#039;s wise to ensure the package list
    is up to date. Typically, this is done by running the command
    <strong class="command">apt update</strong>.
   </p>
   <div class="example" id="install.unix.debian.apt.example">
    <p><strong>Example #1 Debian Install Example with Apache 2</strong></p>
    <div class="example-contents">
<div class="shellcode"><pre class="shellcode"># apt install php-common libapache2-mod-php php-cli</pre>
</div>
    </div>

   </div>
   <p class="simpara">
    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:
   </p>
   <div class="example" id="install.unix.debian.apt.example2">
    <p><strong>Example #2 Stopping and starting Apache once PHP is installed</strong></p>
    <div class="example-contents">
<div class="shellcode"><pre class="shellcode"># /etc/init.d/apache2 stop
# /etc/init.d/apache2 start</pre>
</div>
    </div>

   </div>
 </div>
 <div class="sect2" id="install.unix.debian.config">
  <h3 class="title">Better control of configuration</h3>
   <p class="simpara">
    In the last section, PHP was installed with only core modules. It&#039;s
    very likely that additional modules will be desired, such as
    <a href="book.mysql.php" class="link">MySQL</a>,
    <a href="book.curl.php" class="link">cURL</a>,
    <a href="book.image.php" class="link">GD</a>,
    etc. These may also be installed via the <strong class="command">apt</strong> command.
   </p>
   <div class="example" id="install.unix.debian.config.example">
    <p><strong>Example #3 Methods for listing additional PHP packages</strong></p>
    <div class="example-contents">
<div class="shellcode"><pre class="shellcode"># apt-cache search php
# apt search php | grep -i mysql
# aptitude search php</pre>
</div>
    </div>

   </div>
   <p class="simpara">
    The list of packages will include a large number of packages that includes
    basic PHP components, such as <code class="literal">php-cgi</code>,
    <code class="literal">php-cli</code>, and <code class="literal">php-dev</code>, as well as
    many PHP extensions. When extensions are installed, additional packages
    will be automatically installed as necessary to satisfy the dependencies
    of those packages.
   </p>
   <div class="example" id="install.unix.debian.config.example2">
    <p><strong>Example #4 Install PHP with MySQL, cURL</strong></p>
    <div class="example-contents">
<div class="shellcode"><pre class="shellcode"># apt install php-mysql php-curl</pre>
</div>
    </div>

   </div>
   <p class="simpara">
    APT will automatically add the appropriate lines to the
    different <var class="filename">php.ini</var> related files like 
    <var class="filename">/etc/php/7.4/php.ini</var>,
    <var class="filename">/etc/php/7.4/conf.d/*.ini</var>, etc. and depending on
    the extension will add entries similar to <code class="literal">extension=foo.so</code>.
    However, restarting the web server (like Apache) is required before these
    changes take affect.
   </p>
 </div>
 <div class="sect2" id="install.unix.debian.faq">
  <h3 class="title">Common Problems</h3>
  <ul class="itemizedlist">
   <li class="listitem">
    <span class="simpara">
     If the PHP scripts are not parsing via the web server, then it&#039;s
     likely that PHP was not added to the web server&#039;s configuration
     file, which on Debian may be <var class="filename">/etc/apache2/apache2.conf</var>
     or similar. See the Debian manual for further details.
    </span>
   </li>
   <li class="listitem">
    <span class="simpara">
     If an extension was seemingly installed yet the functions are undefined,
     be sure that the appropriate ini file is being loaded and/or the web
     server was restarted after installation.
    </span>
   </li>
  </ul>
 </div>
</div><?php manual_footer($setup); ?>