cPanel

Create Custom PHP Directives


Overview

Important:
This document only applies to systems that run EasyApache 4.

This document explains how to add custom PHP INI directives to your system’s PHP configuration. This ensures that you can manage them in the Editor Mode of WHM’s MultiPHP INI Editor interface (WHM >> Home >> Software >> MultiPHP INI Editor).

If your system requires extra PHP configuration, you may wish to create custom PHP directives. If you want the system to validate your custom directives, you must add them to the /etc/cpanel/ea4/phpini_directives directory.

How to add a custom PHP directive

To add a custom PHP directive, perform the following steps:

  1. Create the /etc/cpanel/ea4/phpini_directives directory if it does not already exist.

  2. Inside the directory, create a .yaml file that contains a hash of the directives that you wish to add inside the directives key.

    Important:
    The hash inside your .yaml file’s directives key must use the same format as the /usr/local/cpanel/whostmgr/etc/phpini_directives.yaml file.

Your file might resemble the following example:

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
directives:
  directive_foo:
    changeable: PHP_INI_ALL
    default: foo
    multiple: 0
    note: '...'
    section: '...'
    type: string
  directive_bar:
    changeable: PHP_INI_PERDIR
    default: 1
    multiple: 0
    note: '...'
    deprecated: 5.4.0
    section: '...'
    type: boolean
Note:
  • If your new directive already exists, the system ignores it.
  • The system reads the /usr/local/cpanel/whostmgr/etc/phpini_directives.yaml file first, and then reads the files in the /etc/cpanel/ea4/phpini_directives directory in ASCII order. It will use the first occurrence of any directive that it reads from a .yaml file.

Related Articles

Leave a Reply

Your email address will not be published. Required fields are marked *