compiling php from source

Revision as of 13:53, 24 October 2011 by Howard Miller (talk | contribs)

Jump to: navigation, search

Note: You are currently viewing documentation for Moodle 3.1. Up-to-date documentation for the latest stable version of Moodle is probably available here: compiling php from source.

This page shows you how to build PHP from source on Ubuntu or other Debian based distributions. It could no doubt be used as a basis for compiling PHP on other Unix or Linux systems.

It is possible that you may need to do this because the latest versions of Moodle require reasonably new versions of PHP which may not be supported by the packages in your version of PHP - especially "long term support" versions.

This discussion was based on Ubuntu 10.04 which (at the time of writing) is the latest Ubuntu LTS. It does not carry a new enough PHP version for Moodle 2.1.


Assumptions

It is assumed that you will have a basic install of Ubuntu (10.04 in this case) without (specifically) PHP installed and possibly no Apache web server either. If you already have PHP installed (as a package) you will need to remove it first:

sudo apt-get remove php5

Apache web server

You can either install Apache from the Ubuntu packages (recommended) or compile it from source. Compiling from source is simple but you end up (using default settings) with a directory structure that is completely different from the Ubuntu packaged version. This is not covered further here.

To install the package version, it's just

sudo apt-get install apache2 apache2-dev

The -dev package is required in order to build PHP.

Obtaining additional libraries

Moodle requires a significant number of optional PHP modules. Many of these require development libraries to be available on the system before PHP is compiled. This aspect is what makes building PHP from source tricky. If you would like a challenge, all of these can be downloaded as source packages and built from scratch but it is much easier to use the packaged versions. They are installed as follows...

sudo apt-get install \
    libxml2-dev \
    libcurl4-openssl-dev \
    libjpeg-dev \
    libpng-dev \
    libxpm-dev \
    libmysqlclient-dev \
    libpq-dev \
    libicu-dev \
    libfreetype6-dev \
    libldap2-dev