University at Buffalo - The State University of New York
Skip to Content

Step-by-Step Instructions

How to Add PHP Extensions to a Pod

Learn how to add non-standard PHP extensions to your pod.  Most extensions can be installed without additional configurations.  However, some extensions (e.g. oci8) require additional libraries be installed and configured. 

Operating System: Any

Applies To: Faculty or Staff using WebApps

Last Reviewed: July 18, 2017

What is an Extension?

An extension is a piece of code written in C or C++ which will be included into the PHP core when PHP starts. Normally you have some more native functions available after including a extension.  PHP extensions are slightly more difficult to install than PHP libraries.  Examples of PHP extensions include:

  • oci8
  • zip
  • mongodb
  • LDAP
  • curl


Prerequisites

Instructions

1. Add the following files to your code repository in the locations specified.  Replace "<extension_name>" with the name of the extension you would like to install.

.s2i/environment

1.

2.

PHP_INI_SCAN_DIR=/etc/opt/rh/rh-php70/php.d:/opt/app-root/php.d

### Add any additional variables required by the extension below this line ###

.s2i/bin/assemble

1.

2.

3.

4.

5.

6.

7.

8.

9.

10.

11.

12.

13.

14.

15.

16.

### Add any prerequisite steps above this line ###

echo "Installing extension"

mkdir /opt/app-root/php.d

cd /opt/app-root/

pecl bundle <extension_name>

cd <extension_name>

phpize

./configure -q

make

echo "extension=/opt/app-root/<extension_name>/modules/<extension_name>.so" >> /opt/app-root/php.d/<extension_name>.ini

### Repeat lines 4 - 10 for any additional extensions ###

### Do not remove the line below unless you are sure you know what you are doing ###

echo "Running assemble script"

cd /opt/app-root/src/

/usr/libexec/s2i/assemble

2. Follow the steps for How to create a new pod (aka container)

  • Select the php-devel image (or shib-php if you plan to use shibboleth)

Example Repositories

The repositories listed below are complete examples of how to install the extension specified.  You can simply clone the repository and add your own code if you plan to use the extension in the example.

See also

Contact the UBIT Help Center

Have a UBITName? You may also use the UBIT Help Center Online (login required).

(Required)
 
 
(xxx) xxx-xxxx
(Required)
Use your @buffalo.edu email, if known
 
(Required)