Compiling PHP Source on Ubuntu 14.04: Common Errors and Solutions
This guide walks through setting up a LAMP environment on Ubuntu 14.04, cloning the PHP source, configuring and building it, and provides a comprehensive list of compilation errors with step‑by‑step commands to resolve each dependency issue.
This article documents the process of compiling PHP from source on an Ubuntu 14.04 server that already has a LAMP development environment installed. It starts by ensuring required tools are present, then clones the PHP repository, configures a minimal build, and runs the compilation.
Prerequisites
Install Git:
<code>sudo apt-get install git -y</code>Clone the source and install build tools:
<code>git clone https://github.com/php/php-src.git
cd php-src
sudo apt-get install build-essential
./buildconf
./configure --disable-all # minimal PHP for testing
make
./sapi/cli/php -v # -v shows version if build succeeded</code>Common compilation errors and their solutions
Missing libxml2
<code>configure: error: xml2-config not found. Please check your libxml2 installation.</code>Solution:
<code>apt-get install libxml2-dev</code>Missing MySQL client libraries
<code>/usr/bin/mysql_config: No such file or directory</code>Solution:
<code>apt-get install mysql-server mysql-client libmysqlclient-dev</code>PEAR compatibility warnings
<code>Warning: Declaration of PEAR_Installer::download() should be compatible with & PEAR_Downloader::download($params) ...</code>These are warnings; they can be ignored or resolved by updating PEAR packages.
Missing OpenSSL headers
<code>configure: error: Cannot find OpenSSL's</code>Solution:
<code>apt-get install libssl-dev</code>Missing BZip2
<code>checking for BZip2 in default path… not found
configure: error: Please reinstall the BZip2 distribution</code>Solution:
<code>apt-get install libbz2-dev</code>Missing libcurl headers
<code>configure: error: Please reinstall the libcurl distribution – easy.h should be in /include/curl/</code>Solution:
<code>apt-get install libcurl4-openssl-dev</code>Missing JPEG library
<code>configure: error: jpeglib.h not found.</code>Solution:
<code>apt-get install libjpeg-dev</code>Missing PNG library
<code>configure: error: png.h not found.</code>Solution:
<code>apt-get install libpng12-dev</code>Missing FreeType
<code>configure: error: freetype-config not found.</code>Solution:
<code>apt-get install libfreetype6-dev</code>Missing mcrypt
<code>configure: error: mcrypt.h not found. Please reinstall libmcrypt.</code>Solution:
<code>apt-get install libmcrypt-dev</code>Missing pspell
<code>configure: error: Cannot find pspell</code>Solution:
<code>apt-get install libpspell-dev</code>Missing PEAR PHP_Archive
<code>PEAR package PHP_Archive not installed: generated phar will require PHP's phar extension be enabled.</code>Solution:
<code>pear install pear/PHP_Archive</code>Missing recode.h
<code>configure: error: Can not find recode.h anywhere under /usr /usr/local /usr /opt.</code>Solution:
<code>apt-get install librecode-dev</code>After addressing each missing dependency, re‑run ./configure and make until the build completes successfully.
php中文网 Courses
php中文网's platform for the latest courses and technical articles, helping PHP learners advance quickly.
How this landed with the community
Was this worth your time?
0 Comments
Thoughtful readers leave field notes, pushback, and hard-won operational detail here.