PHP cli safe_mode command line limitation

I use the Kohana structure (3.0.9), which generates daily logs. I want to send a log file if it was made a day before CRON runs the script, but after several days of trying, I can’t figure out how to defer safe_mode in PHP CLI modus.

When I run my script on the Internet, there is no problem. But I want to run the script as a CRON task on my Plesk 9.5.2 server (or on the command line as root user). I get the following error:

ErrorException [2]: dir (): SAFE MODE Effective. script that uid 10001 is not allowed to access /var/www/vhosts/mydomain.com/subdomains/mysubdomain/httpdocs/application/logs/2011/01 owned by uid 48 ~ APPPATH / classes / controller / ajax. php [181]

I already disabled SAFE MODE in the Plesk control panel, which works fine for a web request, but is not part of the command line or the CRON task.

I use the following code to check if it works:

$d = dir(APPPATH.'logs/2011/01/');
echo "Handle: " . $d->handle . "\n";
echo "Path: " . $d->path . "\n";
while (false !== ($entry = $d->read())) {
   echo $entry."\n";
}
$d->close();

I can read the APPPATH.'logs / 'directory, as well as the APPPATH.'logs / 2011' directory, but the directory representing every month with daily log files always gives an error.

+3
source share
2 answers

You can currently schedule php script execution from the user interface as follows:

plesk schedule cron url php  script

If you still need to execute the script through the command line, note that the Plesk PHP binaries are placed in:

# 7.0
/opt/plesk/php/7.0/bin/php
# 5.6
/opt/plesk/php/5.6/bin/php
# 5.5
/opt/plesk/php/5.5/bin/php
# and so on

Original answer:

, , , Plesk cron PHP, .

Plesk cron ROOT, PHP ON, , cron Plesk, PHP, , .

, CLI/etc/php.ini, :

/usr/bin/php -q -d safe_mode=Off /var/www/vhosts/path-to-your-php-file.php
+15

safe_mode php.ini CLI?

, php --ini. safe_mode safe_mode = Off.

+1

Source: https://habr.com/ru/post/1786494/


All Articles