Howto: Show and install php extensions on Ubuntu/Debian

You may review the available PHP extensions on your Debian/Ubuntu system by tipping in:

apt-cache search php|egrep ^php5-

your output on a standard Ubuntu/Debian could looks like this:

# apt-cache search php|egrep ^php5-
php5-cgi - server-side, HTML-embedded scripting language (CGI binary)
php5-cli - command-line interpreter for the php5 scripting language
php5-common - Common files for packages built from the php5 source
php5-curl - CURL module for php5
php5-dbg - Debug symbols for PHP5
php5-dev - Files for PHP5 module development
php5-gd - GD module for php5
php5-gmp - GMP module for php5
php5-json - JSON module for php5
php5-ldap - LDAP module for php5
php5-mysql - MySQL module for php5
php5-odbc - ODBC module for php5
php5-pgsql - PostgreSQL module for php5
php5-pspell - pspell module for php5
php5-readline - Readline module for php5
php5-recode - recode module for php5
php5-snmp - SNMP module for php5
php5-sqlite - SQLite module for php5
php5-tidy - tidy module for php5
php5-xmlrpc - XML-RPC module for php5
php5-xsl - XSL module for php5
php5-adodb - Extension optimising the ADOdb database abstraction library
php5-apcu - APC User Cache for PHP 5
php5-enchant - Enchant module for php5
php5-exactimage - fast image manipulation library (PHP bindings)
php5-fpm - server-side, HTML-embedded scripting language (FPM-CGI binary)
php5-gdcm - Grassroots DICOM PHP5 bindings
php5-gearman - PHP wrapper to libgearman
php5-geoip - GeoIP module for php5
php5-gnupg - wrapper around the gpgme library
php5-imagick - ImageMagick module for php5
php5-imap - IMAP module for php5
php5-interbase - interbase/firebird module for php5
php5-intl - internationalisation module for php5
php5-lasso - Library for Liberty Alliance and SAML protocols - PHP 5 bindings
php5-librdf - PHP5 language bindings for the Redland RDF library
php5-mapscript - php5-cgi module for MapServer
php5-mcrypt - MCrypt module for php5
php5-memcache - memcache extension module for PHP5
php5-memcached - memcached extension module for PHP5, uses libmemcached
php5-midgard2 - Midgard2 Content Repository - PHP5 language bindings and module
php5-ming - Ming module for php5
php5-mongo - MongoDB database driver
php5-msgpack - PHP extension for interfacing with MessagePack
php5-mysqlnd - MySQL module for php5 (Native Driver)
php5-mysqlnd-ms - MySQL replication and load balancing module for PHP
php5-oauth - OAuth 1.0 consumer and provider extension
php5-pinba - Pinba module for PHP 5
php5-ps - ps module for PHP 5
php5-radius - PECL radius module for PHP 5
php5-redis - PHP extension for interfacing with Redis
php5-remctl - PECL module for Kerberos-authenticated command execution
php5-rrd - PHP bindings to rrd tool system
php5-sasl - Cyrus SASL Extension
php5-stomp - Streaming Text Oriented Messaging Protocol (STOMP) client module for PHP 5
php5-svn - PHP Bindings for the Subversion Revision control system
php5-sybase - Sybase / MS SQL Server module for php5
php5-tokyo-tyrant - PHP interface to Tokyo Cabinet's network interface, Tokyo Tyrant
php5-vtkgdcm - Grassroots DICOM VTK PHP bindings
php5-xcache - Fast, stable PHP opcode cacher
php5-xdebug - Xdebug Module for PHP 5
php5-xhprof - Hierarchical Profiler for PHP5

To install new php modules on your Ubuntu/Debian, all you need to type in is:

sudo apt-get install php5-curl php5-gd php5-mcrypt

If you need to check what is installed php-wise you can:

dpkg --list | grep php

this could look like this:

 :~# dpkg --list | grep php
ii  libapache2-mod-php5                 5.5.9+dfsg-1ubuntu4.7            amd64        server-side, HTML-embedded scripting language (Apache 2 module)
ii  php5                                5.5.9+dfsg-1ubuntu4.7            all          server-side, HTML-embedded scripting language (metapackage)
ii  php5-cli                            5.5.9+dfsg-1ubuntu4.7            amd64        command-line interpreter for the php5 scripting language
ii  php5-common                         5.5.9+dfsg-1ubuntu4.7            amd64        Common files for packages built from the php5 source
ii  php5-json                           1.3.2-2build1                    amd64        JSON module for php5
ii  php5-mysql                          5.5.9+dfsg-1ubuntu4.7            amd64        MySQL module for php5
ii  php5-readline                       5.5.9+dfsg-1ubuntu4.7            amd64        Readline module for php5

If you want to add the gd library for example, try: php5enmod gd

root@blubb:~# php5enmod gd
WARNING: Module gd ini file doesn't exist under /etc/php5/mods-available

In this case, it didn’t work, so let us install the library using ” apt-get install php5-gd”. The output may look like this:

root@blubb:~# sudo apt-get install php5-gd

Reading package lists... Done
Building dependency tree
Reading state information... Done

The following extra packages will be installed:
  fontconfig-config fonts-dejavu-core libfontconfig1 libgd3 libjbig0
  libjpeg-turbo8 libjpeg8 libtiff5 libvpx1 libxpm4
Suggested packages:
  libgd-tools
The following NEW packages will be installed:
  fontconfig-config fonts-dejavu-core libfontconfig1 libgd3 libjbig0
  libjpeg-turbo8 libjpeg8 libtiff5 libvpx1 libxpm4 php5-gd
0 upgraded, 11 newly installed, 0 to remove and 0 not upgraded.
Need to get 2,239 kB of archives.
After this operation, 7,425 kB of additional disk space will be used.
Do you want to continue? [Y/n] Y
Fetched 2,239 kB in 0s (3,534 kB/s)

Unpacking php5-gd (5.5.9+dfsg-1ubuntu4.7) ...
Processing triggers for man-db (2.6.7.1-1ubuntu1) ...
Processing triggers for libapache2-mod-php5 (5.5.9+dfsg-1ubuntu4.7) ...
Setting up fonts-dejavu-core (2.34-1ubuntu1) ...
Setting up fontconfig-config (2.11.0-0ubuntu4.1) ...
Setting up libfontconfig1:amd64 (2.11.0-0ubuntu4.1) ...
Setting up libjpeg-turbo8:amd64 (1.3.0-0ubuntu2) ...
Setting up libjpeg8:amd64 (8c-2ubuntu8) ...
Setting up libjbig0:amd64 (2.0-2ubuntu4.1) ...
Setting up libtiff5:amd64 (4.0.3-7ubuntu0.3) ...
Setting up libvpx1:amd64 (1.3.0-2) ...
Setting up libxpm4:amd64 (1:3.5.10-1) ...
Setting up libgd3:amd64 (2.1.0-3) ...
Setting up php5-gd (5.5.9+dfsg-1ubuntu4.7) ...

Creating config file /etc/php5/mods-available/gd.ini with new version
php5_invoke: Enable module gd for cli SAPI
php5_invoke: Enable module gd for apache2 SAPI
Processing triggers for libc-bin (2.19-0ubuntu6.6) ...
Processing triggers for libapache2-mod-php5 (5.5.9+dfsg-1ubuntu4.7) ...

Now you may enable the phpmodule and restart the apache:

root@blubb:~# php5enmod gd
root@blubb:~# service apache2 restart
 * Restarting web server apache2

i use a small php test.php script to have a look at the php configuration in a well formated, it looks like this:

<?php
      echo phpinfo();
?>

put it in your webspace and check the output by typing in: www.yourdomain.de/test.php

The installed and enmoded php extension should now be available.

good luck and have fun!

 

Leave a Comment