Customizing PHP Configuration

PHP is one of the most popular scripting languages for creating dynamic web pages. The majority of today's websites and web applications are based on PHP scripts. Thus, site administrators should understand how they can control the execution of PHP scripts. Typically, PHP behavior is defined by a number of configuration settings. These settings specify various script execution aspects, like performance (for example, the amount of memory a script can use), security (for example, access to file system and services), and so on. Administrators might want to adjust these settings for a number of reasons:

  • Preventing a memory leak or server hang-up by poorly written scripts.
  • Protecting data from malicious scripts.
  • Meeting the requirements of a certain web app.
  • Testing own scripts and other.
Custom PHP Settings in Plesk

Generally, PHP settings are defined by the server-wide configuration file. For Linux it is, typically, /etc/php.ini and for Windows - %WIN%\php.ini. This file is managed by your hosting provider and defines PHP configuration for all websites hosted on the server. Since Plesk 10.4, PHP settings are adjustable through the Customer Panel and you can adjust them individually for each hosting plan or subscription. Moreover, your customers (if allowed) can adjust your PHP settings preset individually for each of their websites and subdomains. See the PHP settings hierarchy on the diagram below.

PHP Settings Hierarchy

You can set the custom PHP configuration in the properties of a certain service plan, add-on plan, or subscription (on the PHP Settings tab). PHP settings from a higher level act as a preset for a lower level, thus each lower level overrides them. For example, you can consciously apply some PHP limitations to a service plan and then offer your customers the add-on plan that removes the limitations. PHP settings of the add-on plan will override the settings defined in the main service plan.
If customers have the corresponding permissions, they can specify the PHP configuration that is unique for each website (or subdomain) in their subscription.

Groups of PHP Settings

For convenience, all PHP settings in Plesk are divided into two groups:

  • Performance settings.
    These settings define how scripts work with system resources. For example: Use the memory_limit parameter to limit the amount of memory for a script and, as a consequence, to prevent memory leaks; or prevent scripts from tying up the server by limiting the maximum time scripts are allowed to run in max_execution_time.
  • Common settings.
    This group contains other commonly used PHP settings. Generally, these are: Security settings (say, the PHP safe mode toggle or the permission to register global variables), error reporting settings (say, the directive to log errors), and others.

Important: If you use Plesk for Windows or for Linux, where PHP runs not as an Apache module, your customers are able to override some PHP settings regardless of any permissions. They can use the ini_set() function in their scripts to change values of the following parameters: memory_limit, max_execution_time, and those of your additional directives that PHP allows to set anywhere (PHP_INI_ALL directives; learn more at http://php.net/manual/en/ini.list.php).

If you cannot find particular parameters among performance or common settings, contact your hosting provider.

The Default Values of PHP Parameters

You can set the value of each parameter in PHP Settings either by selecting a value from a preset, typing a custom value, or leaving the Default value. In the latter case, Plesk takes the parameter value from the server-wide PHP configuration. The only exceptions are add-on plans: the value set to Default on the add-on's PHP Settings tab will keep the parameter's value from the main service plan.

Allowing Customers to Change PHP Settings

You can allow your customers to override subscription's PHP settings with their own per-website and per-subdomain PHP configuration. For this purpose, you should use the following permissions on the Permissions tab of a certain service plan or subscription:

  • Hosting performance settings management.
    Along with management of some other settings, this permission grants customers access to PHP settings from the performance settings group.
  • Common PHP settings management.
    If granted, allows customers to adjust PHP settings from the common settings group.

Note that you can toggle these permissions for a plan (subscription) only if it has the granted Hosting settings management permission.

Even if your customers do not have permissions to adjust PHP settings, you (as the administrator) can always perform such per-website (subdomain) PHP configuration. To do this, open a certain hosting account from the Reseller Panel and apply changes to the settings of a particular website (subdomain) on the PHP Settings tab.