How do i enable and install php extensions?

NOTE: We are in the process of modifying the file structure and configuration for many Bitnami stacks. On account of these changes, the file paths stated in this guide may change depending on whether your Bitnami stack uses native Linux system packages [Approach A], or if it is a self-contained installation [Approach B]. To identify your Bitnami installation type and what approach to follow, run the command below:

 $ test ! -f "/opt/bitnami/common/bin/openssl" && echo "Approach A: Using system packages." || echo "Approach B: Self-contained installation."

The output of the command indicates which approach [A or B] is used by the installation, and will allow you to identify the paths, configuration and commands to use in this guide. Refer to the FAQ for more information on these changes.

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

APCu is the APC User Cache module. It is already included in recent Bitnami Stacks by default. If that is not the case, install it manually following the steps below:

  • Install the following packages:

          $ sudo apt-get update
          $ sudo apt-get install build-essential libtool autoconf unzip wget
    
  • Download the latest source package from the web page, uncompress it and compile the module.

      $ wget //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
    

To enable the module, add the following line to the php.ini file:

...
extension = apcu.so
...

MSSQL

Microsoft SQL Server is a relational database management system developed by Microsoft. The steps to install the module differ for PHP5 and PHP7, and Ubuntu and Debian. Choose the appropriate section below depending on the PHP version bundled with your stack and the platform. To obtain the PHP version, use the command php -v at your console prompt.

Installation

You need to install the PHP Linux Drivers for SQL Server. The process is different for Debian and Ubuntu.

Debian
  • Add the microsoft packages to apt-get:

          $ sudo su
          $ curl //packages.microsoft.com/keys/microsoft.asc | apt-key add -
          $ curl //packages.microsoft.com/config/debian/9/prod.list > /etc/apt/sources.list.d/mssql-release.list
          $ curl //packages.microsoft.com/config/debian/9/prod.list > /etc/apt/sources.list.d/mssql-release.list
          $ exit
    
  • Install the tool with apt-get and pecl:

          $ sudo apt-get update
          $ sudo ACCEPT_EULA=Y apt-get install -y msodbcsql17 mssql-tools unixodbc-dev
          $ sudo pecl install sqlsrv
          $ sudo pecl install pdo_sqlsrv
    
  • Edit the /opt/bitnami/php/etc/php.ini file and add the lines below to it:

      $ extension=sqlsrv.so
      $ extension=pdo_sqlsrv.so
    
Ubuntu:
  • Add the microsoft packages to apt-get:

          $ sudo su
          $ curl //packages.microsoft.com/keys/microsoft.asc | apt-key add -
          $ curl //packages.microsoft.com/config/ubuntu/16.04/prod.list > /etc/apt/sources.list.d/mssql-release.list
          $ curl //packages.microsoft.com/config/ubuntu/16.04/prod.list > /etc/apt/sources.list.d/mssql-release.list
          $ exit
    
  • Install the tool with apt-get and pecl:

          $ sudo apt-get update
          $ sudo ACCEPT_EULA=Y apt-get install -y msodbcsql mssql-tools unixodbc-dev
          $ sudo pecl install sqlsrv
          $ sudo pecl install pdo_sqlsrv
    
  • Edit the /opt/bitnami/php/etc/php.ini file and add the lines below to it:

      $ extension=sqlsrv.so
      $ extension=pdo_sqlsrv.so
    

Testing

  • Create a file called “connect.php”:

       $ nano connect.php
    
  • Add the following PHP script, replacing the IP_ADDRESS, PORT and PASSWORD placeholders with their respective values:

       $ 
    
  • Run the test script with the following command:

      $ php connect.php
    

GeoIP2

Apache

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:

          $ sudo apt-get update
          $ sudo apt-get install build-essential libtool autoconf unzip wget
    
  • Install the development files for libgeoip:

          $ sudo apt-get install libgeoip-dev
    
  • Download the latest source code from the web page, uncompress it and compile the module.

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

      $ tar xzf 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 //dev.maxmind.com/geoip/mod_geoip2#Configuration-2.

NGINX

To compile and install the GeoIP2 module for NGINX, it is necessary to first download and compile NGINX from source with the GeoIP2 module included and then copy over the compiled module to the Bitnami stack’s existing NGINX installation. Follow these steps:

  • Install the libmaxminddb-dev library:

      $ sudo apt-get install libmaxminddb-dev
    
  • Download and uncompress the GeoIP2 module source code using the example commands below. Note that the download URL and file name will differ depending on the version you’re downloading.

      $ wget //github.com/leev/ngx_http_geoip2_module/archive/3.2.tar.gz
      $ tar xzf 3.2.tar.gz
    
  • Download and uncompress the NGINX source code using the example commands below. Note that the download URL and file name will differ depending on the version you’re downloading.

    NOTE: Download the source code corresponding to the NGINX version used in your Bitnami stack.

      $ wget //nginx.org/download/nginx-1.18.0.tar.gz
      $ tar xzf nginx-1.18.0.tar.gz
    
  • Compile the module as a dynamic module. Replace the PATH-TO-MODULE-DIRECTORY placeholder with the path to the directory containing the GeoIP2 module source code:

      $ cd nginx-1.18.0
      $ ./configure --add-dynamic-module=PATH-TO-MODULE-DIRECTORY
      $ make
    

    This should create a compiled module file named objs/ngx_http_geoip2_module.so. Copy this file to the temporary directory.

      $ cp objs/ngx_http_geoip2_module.so /tmp/
    
  • Change to the existing NGINX installation directory and copy the above module file to it:

      $ cd /opt/bitnami/nginx
      $ mkdir modules
      $ cp /tmp/ngx_http_geoip2_module.so /opt/bitnami/nginx/modules/
    
  • Edit the /opt/bitnami/nginx/nginx.conf file and add the line below to it in order to load the module:

      load_module modules/ngx_http_geoip2_module.so;
    

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
      ...
    

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 ionCube version number that matches your PHP version.

      $ wget //downloads3.ioncube.com/loader_downloads/ioncube_loaders_lin_x86-64.tar.gz
      $ tar xvzf ioncube_loaders_lin_x86-64.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
    

MongoDB

The Mongo PHP module is a MongoDB driver. It is already included in recent Bitnami Stacks, but not enabled by default. If it is not included in your installation, execute the command below to install the module:

$ sudo pecl install mongodb
...
Build process completed successfully
Installing '/opt/bitnami/php/lib/php/extensions/mongodb.so'
install ok: channel://pecl.php.net/mongodb-1.5.3
configuration option "php_ini" is not set to php.ini location
You should add "extension=mongodb.so" to php.ini

To enable the MongoDB module, follow these steps:

  • Enable the module in the php.ini file:

      ...
      extension=mongodb.so
      ...
    
  • Check if the extension is loaded by executing the following command:

      $ php -i | grep -i mongodb
    

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:

          $ sudo apt-get update
          $ sudo apt-get install build-essential libtool autoconf unzip wget libpcre++-dev libcurl4-gnutls-dev
    
  • Download the latest source code from the web page, uncompress it and compile the module.

      $ wget //pecl.php.net/get/oauth-2.0.5.tgz
      $ tar xzf oauth*
      $ cd oauth-*
      $ 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 by executing the following command:

      $ php -i | grep -i oauth
    

OCI8

Some Bitnami stacks already ship the oci8 module compiled for each platform. This module requires users to download and install both the InstantClient Basic and InstantClient SDK packages for your platform from the Oracle website.

To enable this module, check if the php.ini file includes the line extension=oci8.so. If so, uncomment it by removing the ; character:

extension=oci8.so

If it is not included, it means the oci8 module is not included in your Bitnami stack. To compile and enable it, follow these steps:

  • Compile and install the OCI8 module:

    NOTE: These commands assume that the InstantClient Basic and SDK packages have been extracted and placed in the /home/bitnami/instantclient_19_6 directory. If the packages are in a different location on your system, update the paths shown in the commands below accordingly.

      $ cd /tmp
      $ wget //pecl.php.net/get/oci8-2.2.0.tgz
      $ tar xzf oci8-2.2.0.tgz
      $ cd oci8-2.2.0
      $ phpize
      $ ./configure --with-oci8=instantclient,/home/bitnami/instantclient_19_6
      $ make
      $ sudo make install
    
  • Add the following environment variable to the PHP runtime:

    NOTE: Depending on your installation type, you must add the environment variable to the following locations:

    • Approach A [Bitnami installations using system packages]: /opt/bitnami/scripts/php-env.sh

    • Approach B [Self-contained Bitnami installations]: /opt/bitnami/scripts/setenv.sh

      export LD_LIBRARY_PATH=/home/bitnami/instantclient_19_6${LD_LIBRARY_PATH:+:$LD_LIBRARY_PATH}
    
  • Enable oci8 by adding the following line to the php.ini file:

      extension=oci8.so
    
  • Check 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

To install and enable the PDO_IBM module, follow the steps below:

  • Download and install the IBM 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
    
  • Compile the PDO_IBM module:

      $ wget //pecl.php.net/get/PDO_IBM-1.3.6.tgz
      $ tar xzf PDO_IBM-1.3.6.tgz
      $ cd PDO_IBM-1.3.6
      $ phpize
      $ ./configure
      $ make
      $ sudo make install
    
  • Add the following environment variable to the PHP runtime:

    NOTE: Depending on your installation type, you must add the environment variable to the following locations:

    • Approach A [Bitnami installations using system packages]: /opt/bitnami/scripts/php-env.sh

    • Approach B [Self-contained Bitnami installations]: /opt/bitnami/scripts/setenv.sh

      export LD_LIBRARY_PATH=/home/bitnami/dsdriver/lib${LD_LIBRARY_PATH:+:$LD_LIBRARY_PATH}
    
  • Enable the PDO_IBM module in the 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
    
  • 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

This module is already included in Bitnami Stacks, but not enabled by default. To enable the pdo_pgsql module, edit the php.ini file and add the following line:

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:

          $ sudo apt-get update
          $ sudo apt-get install -y autoconf
    
  • Download the source code from the web page, uncompress it and compile the module:

    NOTE: Replace the VERSION placeholder with your Redis version.

      $ wget //pecl.php.net/get/redis-VERSION.tgz
      $ tar xzf redis-VERSION.tgz
      $ cd redis-VERSION
      $ phpize
      $ ./configure
      $ make
      $ sudo make install
    
  • 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 //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 and setup required system packages:

          $ sudo apt-get update
          $ sudo apt-get install build-essential libtool autoconf unzip wget libcurl4-openssl-dev libxml2-dev
          $ sudo ln -s /usr/include/x86_64-linux-gnu/curl /usr/include/curl
    
  • Download the latest source code from the web page and uncompress it:

      $ wget //pecl.php.net/get/solr-VERSION.tgz
      $ tar xzf solr-VERSION.tgz
      $ cd solr-VERSION
    
  • Compile the module: Depending on your installation type, run the following commands:

    • Approach A [Bitnami installations using system packages]:

        $ phpize
        $ ./configure --enable-solr
        $ make
        $ sudo make install
      
    • Approach B [Self-contained Bitnami installations]:

        $ phpize
        $ ./configure --enable-solr --with-curl=//docs.bitnami.com/opt/bitnami/common --with-libxml-dir=/opt/bitnami/common
        $ make
        $ sudo make install
      
  • Enable the module in the php.ini file:

      ...
      extension=solr.so
      ...
    

SSH2

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

  • Install the libssl-dev package:

          $ sudo apt-get update
          $ sudo apt-get install libssl-dev
    
  • Download and compile libssh2 and ssh2:

      $ cd /tmp
      $ wget //www.libssh2.org/download/libssh2-1.9.0.tar.gz
      $ tar vxzf libssh2-1.9.0.tar.gz
      $ cd libssh2-1.9.0
      $ ./configure
      $ make
      $ sudo make install
      $ cd /tmp
      $ wget //pecl.php.net/get/ssh2-1.2.tgz
      $ tar xzf ssh2-1.2.tgz
      $ cd ssh2-1.2
      $ phpize
      $ ./configure --with-ssh2
      $ make
      $ sudo make install
    
  • Modify the php.ini file to add the following line:

      ...
      extension=ssh2
      ...
    

Tidy

Tidy is a binding for the Tidy HTML clean and repair utility. This binding allows you to clean and manipulate HTML documents and traverse the document tree. This module is enabled by default. Confirm that the module is enabled with the following command:

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

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:


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

How do I install PHP extensions?

Restart your php.
Install the PHP development package..
Download & unzip the PHP5 source code..
Prepare the extension [phpize].
Configure & Make the extension..
Move the extension..
Edit your PHP.INI..
Restart your php..

Where do I enable PHP extensions?

For enable PHP Extension intl , follow the Steps...
Open the xampp/php/php. ini file in any editor..
Search ";extension=php_intl.dll".
kindly remove the starting semicolon [ ; ] Like : ;extension=php_intl.dll. to. extension=php_intl.dll..
Save the xampp/php/php. ini file..
Restart your xampp/wamp..

How do I check if PHP extensions are enabled?

Using Command Line: If you using a command line then you can use the below command to get all module lists. If you want details information, you can use php -i to get phpinfo[]; response. Check specific extensions whether extension is installed or not. If you want to uninstall all modules and install all again.

How do I enable PHP?

First run php -v from command line to know if it return PHP version or any errors to make sure PHP is installed properly or not in your system. Solution 2 : It might be PHP is not enabled in your apache configuration. You can uncomment PHP module by removing '#' sign at the beginning from httpd.

Where can I download PHP extensions?

Downloading PECL extensions ¶ » //pecl.php.net/ The PECL web site contains information about the different extensions that are offered by the PHP Development Team. The information available here includes: ChangeLog, release notes, requirements and other similar details.

Where are PHP extensions located?

extension_dir = : The extension_dir points to the directory where the PHP extensions are stored. The path can be fully qualified [for example, C:\PHP\ext ] or relative [for example, . \ext].

Bài mới nhất

Chủ Đề