Advertising sustains the DA. Ads are hidden for members. Join today

Building and installing the PHP GDAL extension

Last updated on
30 April 2025

This module depends on the PHP GDAL extension. It can be downloaded from https://github.com/geops/php5-gdal.

Currently the extension is only distributed in source form, so it has to be built before it can be used. The build itself depends on the PHP development files, the GDAL library, PHP JSON and its development files as well as a working C++ compiler.

On Debian and Ubuntu based systems these dependencies can be installed by the following command:

sudo apt-get install php5-dev g++ libgdal1-dev  make php5-json

After the dependencies are installed the extension itself can be built by running the following commands inside the directory of the source code:

phpize
./configure
make

To install the extension on your system you have to run:

sudo make install

To register the extension with PHP you have to add it to the PHP configuration. On Debian/Ubuntu based systems this can be done by creating a file /etc/php5/mods-available/gdal.ini with the following content:

; configuration for the PHP GDAL extension
extension=gdal.so

Enable the new extension with the following command :

sudo php5enmod gdal

If you are running PHP via Apache's mod_php or php_fpm you will have to restart this service for the extension being loaded.

Help improve this page

Page status: Not set

You can: