Source of: /manual/en/install.unix.debian.php
<?php
include_once $_SERVER['DOCUMENT_ROOT'] . '/include/shared-manual.inc';
$TOC = 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 => 'en',
),
'this' =>
array (
0 => 'install.unix.debian.php',
1 => 'Debian GNU/Linux installation notes',
),
'up' =>
array (
0 => 'install.unix.php',
1 => 'Installation on Unix systems',
),
'prev' =>
array (
0 => 'install.unix.solaris.php',
1 => 'Solaris specific installation tips',
),
'next' =>
array (
0 => 'install.macosx.php',
1 => 'Installation on Mac OS X',
),
);
$setup["toc"] = $TOC;
$setup["parents"] = $PARENTS;
manual_setup($setup);
manual_header();
?>
<div id="install.unix.debian" class="sect1">
<h2 class="title">Debian GNU/Linux installation notes</h2>
<p class="para">
This section contains notes and hints specific to installing
PHP on <a href="http://www.debian.org/" class="link external">» Debian GNU/Linux</a>.
</p>
<p class="para">
While the instructions for building PHP on Unix apply to Debian as well,
this manual page contains specific information for other options, such as
using either the <i>apt-get</i> or <i>aptitude</i>
commands. This manual page uses these two commands interchangeably.
</p>
<div id="install.unix.debian.apt" class="sect2">
<h3 class="title">Using APT</h3>
<p class="simpara">
First, note that other related packages may be desired like
<i>libapache2-mod-php5</i> to integrate with Apache 2, and
<i>php-pear</i> for PEAR.
</p>
<p class="simpara">
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
<strong class="command">apt-get update</strong>.
</p>
<div class="example">
<p><b>Example #1 Debian Install Example with Apache 2</b></p>
<div class="example-contents programlisting">
<div class="shellcode"><pre class="shellcode"># apt-get install php5-common libapache2-mod-php5 php5-cli</pre>
</div>
</div>
</div>
<p class="simpara">
APT will automatically install the PHP 5 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">
<p><b>Example #2 Stopping and starting Apache once PHP is installed</b></p>
<div class="example-contents programlisting">
<div class="shellcode"><pre class="shellcode"># /etc/init.d/apache2 stop
# /etc/init.d/apache2 start</pre>
</div>
</div>
</div>
</div>
<div id="install.unix.debian.config" class="sect2">
<h3 class="title">Better control of configuration</h3>
<p class="simpara">
In the last section, PHP was installed with only core modules. It'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 <i>apt-get</i> command.
</p>
<div class="example">
<p><b>Example #3 Methods for listing additional PHP 5 packages</b></p>
<div class="example-contents programlisting">
<div class="shellcode"><pre class="shellcode"># apt-cache search php5
# aptitude search php5
# aptitude search php5 |grep -i mysql</pre>
</div>
</div>
</div>
<p class="simpara">
The examples will show a lot of packages including several PHP specific ones
like php5-cgi, php5-cli and php5-dev. Determine which are needed
and install them like any other with either <i>apt-get</i>
or <i>aptitude</i>. And because Debian performs
dependency checks, it'll prompt for those so for example to install
MySQL and cURL:
</p>
<div class="example">
<p><b>Example #4 Install PHP with MySQL, cURL</b></p>
<div class="example-contents programlisting">
<div class="shellcode"><pre class="shellcode"># apt-get install php5-mysql php5-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/php5/apache2/php.ini</var>,
<var class="filename">/etc/php5/conf.d/pdo.ini</var>, etc. and depending on
the extension will add entries similar to <i>extension=foo.so</i>.
However, restarting the web server (like Apache) is required before these
changes take affect.
</p>
</div>
<div id="install.unix.debian.faq" class="sect2">
<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's
likely that PHP was not added to the web server'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>
<li class="listitem">
<span class="simpara">
There are two basic commands for installing packages on Debian (and other
linux variants): <i>apt-get</i> and <i>aptitude</i>.
However, explaining the subtle differences between these commands goes
beyond the scope of this manual.
</span>
</li>
</ul>
</div>
</div><?php manual_footer(); ?>