Plesk

Plesk scheduled tasks fail due to domain PHP settings not taking effect

Symptoms

  1. Cannot run PHP script via Domains > example.com > Scheduled Tasks:

    PHP Warning: file_get_contents(): http:// wrapper is disabled in the server configuration by allow_url_fopen=0 in /var/www/vhosts/example.com/cron/task.php on line

  2. 'allow_url_fopen' directive is set to 'Off' in the server-wide PHP handler configuration:

    # grep -i 'allow_url_fopen'
    /opt/plesk/php/7.0/etc/php.ini allow_url_fopen=Off

  3. Domain example.com has the same PHP handler selected in Domains > example.com > PHP Settings and allow_url_fopen directive is set to 'On'

OR

Cause

Custom PHP settings of the domain are not applicable for scheduled task, only directives from global php.ini take effect.

Resolution

Using domain PHP settings for PHP script run by scheduled task is yet to be implemented in Plesk.

Vote for this feature at Plesk UserVoice portal.

The top-ranked suggestions are likely to be included in the next versions of Plesk.

Use either of the following workarounds:

Workaround I

Use Run a command option instead of Run a PHP script in Domains > example.com > Scheduled Tasks. For example, to run
/var/www/vhosts/example.com/cron/task.php
:

/opt/plesk/php/7.0/bin/php -c /var/www/vhosts/system/example.com/etc/php.ini -f '/var/www/vhosts/example.com/cron/task.php'

Pay attention, that 'Access to the server over SSH' should be set as /bin/bash. In order to make it available via /bin/bash (chrooted), refer to this article.

Workaround II

  1. Go to Domains > example.com > PHP Settings and identify PHP handler assigned to the domain
  2. Go to Tools & Settings > PHP Settings, click the handler identified on the previous step and change the required setting there.
Exit mobile version