How do I get a PHP configuration value or version changed?

Problem Description

  • You wish to change a PHP configuration value
  • You wish to change the PHP version
  • You receive an error like one of the following:
    • The uploaded file exceeds the upload_max_filesize directive in php.ini.
    • Allowed memory size of 67108864 bytes exhausted 

By default all of our servers are configured to run PHP via FastCGI or occasionally with PHP-FPM and nginx. This means that setting PHP configuration values via the .htaccess file does not work. This is because .htaccess is an apache configuration file, but PHP isn't running directly within the apache web server.

Solution

To change the PHP version or adjust a PHP configuration value, you can configure it within Plesk which will then configure PHP accordingly regardless of the run-mode (FastCGI, Apache Module, PHP-FPM). Here's how:

  1. Login to Plesk
  2. Choose the Websites & Domains tab.
  3. Find your domain in the list, then, if you don't see a "PHP Settings" button, click the little arrow at the bottom of its box (or Show More in Plesk 12+).
  4. Choose the PHP Settings button
  5. The most common PHP configuration values that need to be edited are available here for you to change. Make the changes you need and choose the OK button when you're done. Examples:
    1. If you get an error about exceeding the upload_max_filesize directive, increase that value until you no longer get the error.
    2. If you get an error about the allowed memory size being exhausted, increase the memory limit shown.
    3. If you do not see the directive you need to change, you may have an 'Additional Directives' box at the bottom of the page where you can enter it manually, for example: date.timezone = "America/Halifax"

The changes may take at most 10 minutes to apply; in most cases they're instant.

If the PHP Setting you want to change is not available in the list of Plesk options, fear not! You can use a .user.ini file to manually override many PHP settings. Here's how:

  1. Login to Plesk
  2. Choose the Websites & Domains tab.
  3. Find your domain in the list, then, click the web root folder (or File Manager, and navigate to the web root folder)
  4. Edit your .user.ini file if one exists, or click "New" and "New File" - name it .user.ini (the .'s are important!!) 
  5. Enter the php configuration as if it was going into a PHP file. For example: date.timezone=America/Halifax
Once adjusted, the PHP-FPM Process should pick up the changes immediately (or within just a minute or two).

If you are on a managed server feel free to open a ticket and ask us to take care of this for you. Include the domain and php configuration values you wish to adjust and we will apply the configuration parameters accordingly.

Plesk VPS 

The following options are for those with their own VPS only.

instead of using the Additional Directives section in the Plesk GUI, you may alternatively edit /var/www/vhosts/system/<domain>/conf/php.ini and enter the same values there.

Advanced: PHP-FPM

Unfortunately if you wish to adjust the php-fpm specific configuration values (like pm.max_children), you can only do this via the /var/www/vhosts/system/<domain>/conf/php.ini file. Don’t mistake this for the etc/php.ini file, also found in the domain root, as they are not the same. The php.ini in the domain’s etc directory is overwritten by Plesk regularly. Here is an example of what you might put in conf/php.ini:

[php-fpm-pool-settings]
pm.max_children = 35

To actually apply that config to the domain’s php-fpm configuration file, you then need to run the following command (read the note below before running it!) Upon running the command, Plesk will auto-populate the bottom of /etc/php-fpm.d/<domain>.conf with the values you inserted into the conf/php.ini file.

/usr/local/psa/bin/php_settings -u

Note: as of Plesk 12.0.x and 12.5.x (not yet tested with Onyx) there is a performance issue with the php_settings command in that you can only update ALL domains at once rather than a singular domain at a time. Check the source below for more details.

Even more advanced:

If you are only editing a single vhost (seems likely) you can also manually configure the direct php-fpm file. By editing both the actual config file and the Plesk conf/php.ini file, you ensure that the settings take effect immediately with minimal performance implications AND if Plesk ever reconfigures the php configuration (such as during a repair of the entire server config).

To mirror the above directives and actually apply them manually to live php-fpm processing, edit /etc/php-fpm.d/<domain>.conf and insert the following at the bottom:

; php.ini custom configuration directives
pm.max_children = 35

Then restart php-fpm:

/sbin/service php-fpm restart

Note: The above referenced PHP config file applies only to the system installed version of PHP (probably 5.3 or 5.4). If you wish to apply the config manually to a domain using a Plesk PHP binary, you will need to find its config in the /opt/plesk/php directory and edit it there, then restart it using service plesk-php70-fpm restart (where the number 70 refers to PHP 7.0 -- you may replace that with whatever version you're editing).

Source for php-fpm overrides

  • 4 Users Found This Useful