Installing PHP from source on Debian

This page lists common error messages and their solution when installing php from source on Debian.

Apache handler

apxs not found
 aptitude install apache2-prefork-dev


libbz2 + libbz2-dev


configure:46794: checking for IMAP support
configure:46841: checking for IMAP Kerberos support
configure:46867: checking for IMAP SSL support
configure:47275:19: error: /mail.h: No such file or directory
aptitude install libc-client-dev

Installing PHP with apxs

apxs:Error: Activation failed for custom /etc/apache2/httpd.conf file..
apxs:Error: At least one `LoadModule' directive already has to exist..
make: *** [install-sapi] Error 1
Original Solution

See Debian bug #231134

Edit /etc/apache2/httpd.conf and add

#LoadModule dummy_module /usr/lib/apache2/modules/
Current Solution on Ubuntu

This issue is in the process of being fixed (Ubuntu bug #500703). Until then, add the configuration files manually and force the install to continue.

Edit /etc/apache2/mods-available/php5.load and add:

LoadModule php5_module /usr/lib/apache2/modules/

Edit /etc/apache2/mods-available/php5.conf and put in:

<IfModule mod_php5.c>
  AddType application/x-httpd-php .php
  AddType application/x-httpd-php-source .phps

During the make install step, use the -k flag. The -k flag means “keep going when some targets can't be made.” The output will still show the apxs error, but the installation should work. Do keep an eye out for other compile errors.

make install -k

Then enable the php5 module and restart Apache:

a2enmod php5
/etc/init.d/apache2 restart
doc/installation/debian.txt · Last modified: 2017/09/22 13:28 (external edit)