googlemoodle

Install different PHP modules

To install a PHP module, the typical process is to install the module (either via the package manager or through a manual build/install process) and then activate it in the above configuration file. Find instructions for installing specific PHP modules.

NOTE: Bitnami stacks already include a number of PHP modules, which are installed but not active. Before installing a new module, check that it is not already included. If it exists, simply enable it in the PHP configuration file.

After modifying the PHP configuration file, restart both Apache and PHP-FPM for the changes to take effect:

$ sudo /opt/bitnami/ctlscript.sh restart apache
$ sudo /opt/bitnami/ctlscript.sh restart php-fpm

APCu

NOTE: The APCu module is only compatible with PHP 7.x.

APCu is the APC User Cache module. Install it manually following the steps below:

  • Install the following packages:

    • Debian:

      $ sudo apt-get update
      $ sudo apt-get install build-essential libtool autoconf unzip wget
      
    • CentOS:

      $ sudo yum groups mark install "Development Tools"
      
  • Download the latest source package from the web page, uncompress it and compile the module.

    $ wget https://pecl.php.net/get/apcu-X.Y.Z.tgz
    $ tar xzf apcu-X.Y.Z.tgz
    $ cd apcu-X.Y.Z
    $ phpize
    $ ./configure --with-php-config=/opt/bitnami/php/bin/php-config
    $ make
    $ sudo make install
    
  • Enable the module by adding the following line in the php.ini file:

    ...
    extension = apcu.so
    ...
    

eAccelerator

eAccelerator is a free open-source PHP accelerator and optimizer. It increases the performance of PHP scripts by caching them in their compiled state, so that the overhead of compiling is almost completely eliminated. It also optimizes scripts to speed up their execution.

Follow the steps below to install this module:

  • Install the following packages:

    • Debian:

      $ sudo apt-get update
      $ sudo apt-get install build-essential libtool autoconf unzip wget
      
    • CentOS:

      $ sudo yum groups mark install "Development Tools"
      
  • Download the latest source code from the eAccelerator web page, copy to the server, uncompress it and compile the module:

    $ unzip eaccelerator-*.zip
    $ export PHP_AUTOCONF=/usr/bin/autoconf
    $ export PHP_PREFIX=/opt/bitnami/php
    $ cd eaccelerator-0.9.6.1
    $ /opt/bitnami/php/bin/phpize
    $ ./configure --enable-eaccelerator=shared --with-php-config=$PHP_PREFIX/bin/php-config
    $ make
    $ sudo make install
    
  • Enable the module in the php.ini file:

    ...
    extension=eaccelerator.so
    ...
    
  • Check it and verify that the output looks similar:

    $ php -version
    
    Zend Engine v2.1.0, Copyright (c) 1998-2006 Zend Technologies
        with eAccelerator v0.9.5-beta2, Copyright (c) 2004-2006 eAccelerator, by eAccelerator
    

Now, configure this module in the php.ini file. For more information, refer to http://eaccelerator.net/wiki/InstallFromSource.

FreeTDS and MSSQL

FreeTDS is a set of libraries for Unix and Linux that allow your programs to natively talk to Microsoft SQL Server and Sybase databases.

NOTE: Since LAMP stack v5.4.25, this module is already included so it is only necessary to enable the module in the php.ini file.

Follow these steps:

  • Load the build environment and add -liconv to the LDFLAGS:

    $ .  /opt/bitnami/scripts/build-setenv.sh
    $ export LDFLAGS="$LDFLAGS -liconv"
    
  • Install FreeTDS:

    $ wget ftp://ftp.freetds.org/pub/freetds/stable/freetds-patched.tar.gz
    $ tar zxf freetds-patched.tgz
    $ cd freetds-0.95.21/
    $ ./configure --enable-msdblib --prefix=/usr/local/freetds
    $ make
    $ sudo make install
    $ cd ..
    
  • Compile and install the MSSQL module for PHP. Note that you should download the module that matches the PHP version in use. Check the current PHP version with the php -v command.

    $ wget http://us.php.net/distributions/php-5.4.45.tar.bz2
    $ tar jxf php-5.4.45.tar.bz2
    $ cd php-5.4.45/ext/mssql/
    $ phpize
    $ ./configure --with-mssql=/usr/local/freetds
    $ make
    $ sudo make install
    
  • Confirm that the mssql.so library has been copied to the /opt/bitnami/php/lib/php/extensions/ directory.

  • Edit the /opt/bitnami/php/etc/php.ini file and add the line below to it:

    extension=mssql.so
    
  • Restart the server:

    $ sudo /opt/bitnami/ctlscript.sh restart apache
    

GeoIP2

The mod_geoip2 module embeds GeoIP database lookups into the Apache web server. It is only capable of looking up the IP address of a client that connects to the web server, as opposed to looking up arbitrary addresses.

If this module is not in your stack, you can install it manually following the steps below.

  • Install the following packages if necessary:

    • Debian:

      $ sudo apt-get update
      $ sudo apt-get install build-essential libtool autoconf unzip wget
      
    • CentOS:

      $ sudo yum groups mark install "Development Tools"
      
  • Install the development files for libgeoip:

    • Debian:

      $ sudo apt-get install libgeoip-dev
      
    • CentOS:

      $ sudo yum install GeoIP
      
  • Download the latest source code from the web page, uncompress it and compile the module.

    $ wget http://www.maxmind.com/download/geoip/api/mod_geoip2/mod_geoip2-latest.tar.gz
    
  • Uncompress it and build the libraries

    $ tar -xzvf mod_geoip2-latest.tar.gz
    $ cd mod_geoip2_*
    $ sudo apxs -i -a -lGeoIP -c mod_geoip.c
    

    The module should now be available at /opt/bitnami/apache2/modules/mod_geoip.so. It is also automatically included in your Apache configuration.

  • Enable GeoIP in the Apache configuration by adding the line GeoIPEnable On in the /opt/bitnami/apache2/conf/httpd.conf file. Find other specific configuration settings at http://dev.maxmind.com/geoip/mod_geoip2#Configuration-2.

  • Restart the Apache server:

    $ sudo /opt/bitnami/ctlscript.sh restart apache
    

Imagick

The Imagick module is installed in Bitnami stacks, but is not enabled by default. To enable it, follow these steps:

  • Uncomment or add the following line to the /opt/bitnami/php/etc/php.ini file:

    ...
    extension=imagick.so
    ...
    
  • Restart the Apache server and/or the PHP-FPM service (if available):

    $ sudo /opt/bitnami/ctlscript.sh restart apache
    $ sudo /opt/bitnami/ctlscript.sh restart php-fpm
    

IonCube

Follow these steps:

  • Download the pre-compiled version and copy the .so file to the PHP extensions directory. It is very important to install the right version of Ioncube taking into account the PHP version included in your solution. For example, if you want to install Ioncube on WordPress and it uses PHP 7.0.27, you need to install the version 7.0 of Ioncube.

    NOTE: Y and Z are placeholders. Remember to replace them with the corresponding Ioncube version number.

    $ wget http://downloads3.ioncube.com/loader_downloads/ioncube_loaders_lin_xY-Z.tar.gz
    $ tar xvzf ioncube_loaders_lin_xY-Z.tar.gz
    $ sudo cp ioncube/ioncube_loader_lin_Y.Z.so /opt/bitnami/php/lib/php/extensions/
    
  • Add the following line to the php.ini file:

    zend_extension = /opt/bitnami/php/lib/php/extensions/ioncube_loader_lin_Y.Z.so
    
  • Restart PHP-FPM and Apache.

Memcache

The memcache module provides a handy procedural and object-oriented interface to memcached, the highly effective caching daemon, which was especially designed to decrease database load in dynamic web applications.

If this module is not in your stack, you can install it manually following these steps:

  • Install the following packages:

    • Debian:

      $ sudo apt-get update
      $ sudo apt-get install build-essential libtool autoconf unzip wget
      
    • CentOS:

      $ sudo yum groups mark install "Development Tools"
      
  • Download the latest source code from the web page, uncompress it and compile the module.

    $ wget http://pecl.php.net/get/memcache-2.2.7.tgz
    $ tar -zxf memcache-2.2.7.tgz
    $ export PHP_AUTOCONF=/usr/bin/autoconf
    $ export PHP_PREFIX=/opt/bitnami/php
    $ cd memcache-2.2.7
    $ /opt/bitnami/php/bin/phpize
    $ ./configure --enable-memcache --with-zlib-dir=/opt/bitnami/common
    $ make
    $ sudo make install
    
  • Enable the module in the php.ini file:

    ...
    extension=memcache.so
    ...
    

Mongo

The Mongo PHP module is a MongoDB driver.

If this module is not in your stack, you can install it manually following these steps:

  • Compile and install the module:

    $ sudo pecl install mongo
    ...
    Build process completed successfully
    Installing '/opt/bitnami/php/lib/php/extensions/<wbr>mongo.so'
    install ok: channel://pecl.php.net/mongo-<wbr>1.4.5</wbr><wbr>
    configuration option "php_ini" is not set to php.ini location
    You should add "extension=mongo.so" to php.ini</wbr></wbr>
    
  • Enable the module in the php.ini file:

    ...
    extension=mongo.so
    ...
    
  • Restart Apache:

    $ /opt/bitnami/ctlscript.sh restart
    

OAuth

OAuth is an authorization protocol built on top of HTTP which allows applications to securely access data without having to store usernames and passwords.

Follow these steps:

  • Install the following packages:

    • Debian:

      $ sudo apt-get update
      $ sudo apt-get install build-essential libtool autoconf unzip wget
      
    • CentOS:

      $ sudo yum groups mark install "Development Tools"
      
  • Download the latest source code from the web page, uncompress it and compile the module.

    $ wget http://pecl.php.net/get/oauth-1.2.2.tgz
    $ tar -zxf oauth*
    $ export PHP_AUTOCONF=/usr/bin/autoconf
    $ export PHP_PREFIX=/opt/bitnami/php
    $ cd oauth-*
    $ /opt/bitnami/php/bin/phpize
    $ ./configure
    $ make
    $ sudo make install
    
  • Enable the module by adding the following line in the php.ini file:

    ...
    extension = '/opt/bitnami/php/lib/php/extensions/oauth.so'
    ...
    
  • Check if the extension is loaded with the following command:

    $ php -i | grep -i oauth
    

OCI8

Since LAMP/MAMP/WAMP stacks v5.4.34, 5.5.18 and 5.6.2, Bitnami stacks ship the oci8 module already compiled for each platform. This module requires users to download and install the InstantClient libraries from Oracle.

Follow these steps:

  • Enable the oci8 module in the /opt/bitnami/php/etc/php.ini file.

  • Check if the module is active:

    $ /opt/bitnami/php/bin/php -m
    
  • In case you see an error, download the InstantClient Basic package for your platform from the Oracle website.

  • Extract the package contents in your home folder.

  • Add the following environment variable to the end of your /opt/bitnami/scripts/setenv.sh file:

    LD_LIBRARY_PATH=/home/bitnami/instantclient_11_2:$LD_LIBRARY_PATH
    export LD_LIBRARY_PATH
    
  • Restart the servers:

    $ sudo /opt/bitnami/ctlscript.sh restart
    
  • Check again if the module is active:

    $ /opt/bitnami/php/bin/php -m
    

OpenSSL

The OpenSSL module for PHP is already enabled and no additional configuration is required.

pdo_ibm

The Bitnami LAMP Stack includes the PDO_IBM module but it is necessary to activate it. To do this, follow the steps below:

  • Enable the PDO_IBM module in the /opt/bitnami/php/etc/php.ini file by adding the following line:

    extension=pdo_ibm.so
    
  • Check if the module is enabled with the following command:

    $ /opt/bitnami/php/bin/php -m
    
  • In case you see a PHP warning, download the Data Server Driver Package for your platform from the IBM website.

  • Extract the package contents to your home folder and install it by running the following commands:

    $ cd /home/bitnami/dsdriver
    $ bash installDSDriver
    
  • Add the following environment variable at the end of your /opt/bitnami/scripts/setenv.sh* file:

    LD_LIBRARY_PATH=/home/bitnami/dsdriver/lib:$LD_LIBRARY_PATH
    export LD_LIBRARY_PATH
    
  • Restart the server:

    $ sudo /opt/bitnami/ctlscript.sh restart apache
    
  • Check again if the module is active. If it is, no warning will be displayed.

    $ /opt/bitnami/php/bin/php -m | grep ibm
    

pdo_pgsql

Install the pdo_pgsql module by following these steps:

  • Download the module source code and extract it:

    $ pecl download pdo_pgsql
    $ tar xzf PDO_PGSQL-1.0.2.tgz
    
  • Compile the code:

    $ cd PDO_PGSQL-1.0.2
    $ phpize
    $ ./configure --with-pdo-pgsql=/path/to/your/PostgreSQL/installation
    $ make && sudo make install
    
  • Confirm that the pdo_pgsql.so extension is available at /opt/bitnami/php/lib/php/extensions.

  • Enable the module by adding the following line to the /opt/bitnami/php/etc/php.ini file inside the “Dynamic Extensions” section:

    extension=pdo_pgsql.so
    

Redis

The phpredis extension provides an API for communicating with the Redis key-value store. Follow these steps to install it:

  • Install the following package:

    • Debian:

      $ sudo apt-get update
      $ sudo apt-get install -y autoconf
      
    • CentOS:

      $ sudo yum groups mark install "Development Tools"
      
  • Download the latest source code from the web page, uncompress it and compile the module:

    $ wget https://pecl.php.net/get/redis-VERSION.tgz
    $ tar -xvf redis-VERSION.tgz
    $ cd redis-VERSION
    $ phpize
    $ ./configure
    $ make
    $ sudo make install
    

    Replace VERSION placeholder with the correct value for the latest Redis version.

  • Enable the module in the /opt/bitnami/php/etc/php.ini file by adding this line to the end:

    extension=redis.so
    
  • Check that the module was correctly installed with the following command:

    $ php -m | grep redis
    

More information can be found in the official documentation at https://github.com/phpredis/phpredis.

Solr

The Apache Solr PHP extension is an extremely fast, light-weight, feature-rich library that allows PHP applications to communicate easily and efficiently with Apache Solr server instances using an object-oriented API.

If this module is not in your stack, install it manually following these steps:

  • Install the following packages:

    • Debian:

      $ sudo apt-get update
      $ sudo apt-get install build-essential libtool autoconf unzip wget
      
    • CentOS:

      $ sudo yum groups mark install "Development Tools"
      
  • Download the latest source code from the web page, uncompress it and compile the module:

    $ wget http://pecl.php.net/get/solr-1.0.2.tgz
    $ tar -zxf solr-1.0.2.tgz
    $ export PHP_AUTOCONF=/usr/bin/autoconf
    $ export PHP_PREFIX=/opt/bitnami/php
    $ cd solr-1.0.2
    $ /opt/bitnami/php/bin/phpize
    $ ./configure --enable-solr --with-curl=/opt/bitnami/common --with-libxml-dir=/opt/bitnami/common
    $ make
    $ sudo make install
    
  • Enable the module in the php.ini file:

    ...
    extension=solr.so
    ...
    
  • Restart the server:

    $ sudo /opt/bitnami/ctlscript.sh restart apache
    

SSH2

Install and enable the SSH2 module for PHP by following these steps:

  • Install the libssl-dev package:

    • Debian:

      $ sudo apt-get update
      $ sudo apt-get install libssl-dev
      
    • CentOS: the libssl-dev package is installed by default. You can check it by executing yum info openssl.

  • Download and compile libssh2 and ssh2:

    $ cd /tmp
    $ wget http://www.libssh2.org/download/libssh2-1.4.3.tar.gz
    $ tar vxzf libssh2-1.4.3.tar.gz
    $ cd libssh2-1.4.3
    $ ./configure
    $ make
    $ make install
    $ cd /tmp
    $ wget http://pecl.php.net/get/ssh2-0.12.tgz
    $ tar vxzf ssh2-0.12.tgz
    $ cd ssh2-0.12
    $ phpize
    $ ./configure --with-ssh2
    $ make
    $ make install
    
  • Copy the ssh2.so file into the shared extensions folder at /opt/bitnami/php/lib/php/extensions/ and modify the /opt/bitnami/php/etc/php.ini file to add the following line:

    ...
    extension=ssh2.so
    ...
    
  • Restart the server and you will now have the ability to run SSH2 commands.

Thanks to @Chris_James for posting this guide!

Tidy

Tidy is a binding for the Tidy HTML clean and repair utility which allows you to not only clean and otherwise manipulate HTML documents, but also traverse the document tree.

If this module is not in your stack, you can install it manually following these steps:

  • Install the following packages (they are already in the machine in recent versions):

    • Debian:

      $ sudo apt-get update
      $ sudo apt-get install build-essential libtool autoconf unzip wget
      
    • CentOS:

      $ sudo yum groups mark install "Development Tools"
      
  • Download the latest source code from the web page, uncompress it and compile the module:

    $ wget http://tidy.cvs.sourceforge.net/viewvc/tidy/tidy/?view=tar
    
  • Uncompress it and build the libraries:

    $ cd /home/bitnami
    $ tar -xzvf tidy-tidy.tar.gz
    $ cd tidy/build/gmake
    $ make
    
  • Download the PHP source code version that you are currently using and uncompress it. Then, build the shared module for tidy:

    $ tar -xzvf php-VERSION.tar.gz
    $ cd php/ext/tidy
    $ ./phpize
    $ ./configure --with-tidy=/home/bitnami/tidy
    $ make
    $ sudo make install
    

XCache

The XCache module is installed in Bitnami stacks, but is not enabled by default. To enable it, follow these steps:

  • Add the following lines to the /opt/bitnami/php/etc/php.ini file:

    ...
    [xcache-common]
    extension=xcache.so
    ...
    
  • Restart the Apache server to include the new configuration:

    $ sudo /opt/bitnami/ctlscript.sh restart apache
    

Install the XCache administration page

Once XCache is installed, add the XCache administration page to obtain information on cache operations. This is not included by default, so follow the steps below:

  • Download the complete tarball containing the XCache Administration Page for the XCache version included in the Bitnami stack. Find XCache versions at http://xcache.lighttpd.net. To check your current XCache version, use the command php -v.

  • Extract the tarball content and use the htdocs folder to enable the XCache administration page.

  • Generate and save your authentication password. The XCache administration page is protected with HTTP authentication. Edit your php.ini file and add these lines to include your user and password.

    xcache.admin.user = "user"
    xcache.admin.pass = "6a4dc9133d5f3b6d9fff778aff361961"
    

    The password must be specified in MD5 format. Here is a simple PHP script that returns the encrypted MD5 version of a plaintext password:

    <?php
    echo md5("password");
    ?>
    
  • Create a new xcache directory and add the Apache configuration files to it. Find out how to create a custom application.

  • Access your XCache administration page through your browser.

Zend Guard Loader

Zend Guard is a free runtime application that enables PHP to run scripts encoded by Zend Guard. It can be freely used by anyone looking to run encoded applications. Follow these steps:

  • Download the binary version of the extension from the Zend Guard site.

  • Run the following commands:

    $ tar -xzvf  ZendGuardLoader-*-PHP-5.4-linux-glibc23-x86_64.tar.gz
    $ sudo cp ZendGuard*/php-5.4.x/ZendGuardLoader.so /opt/bitnami/php/lib/php/extensions/
    
  • Add the following entry to the end of the php.ini file:

    zend_extension = /opt/bitnami/php/lib/php/extensions/ZendGuardLoader.so
    
  • Check that the module was correctly installed with the following command:

    $ php -m | grep Zend
    

ZipArchive

ZipArchive is a class of the zip PHP module. This module is enabled by default. Check it with the following command:

$ sudo /opt/bitnami/php/bin/php -m | grep zip
zip

Here is a script named sample.php that lists the content of a zip file named sample.zip:

<?php
$za = new ZipArchive();
$za->open('sample.zip');
for( $i = 0; $i < $za->numFiles; $i++ ){
    $stat = $za->statIndex( $i );
    print_r( basename( $stat['name'] ) . PHP_EOL );
}
?>

To use this script, create a sample.zip file and run this script at the server console, as below:

$ /opt/bitnami/php/bin/php sample.php