• If you are still using CentOS 7.9, it's time to convert to Alma 8 with the free centos2alma tool by Plesk or Plesk Migrator. Please let us know your experiences or concerns in this thread:
    CentOS2Alma discussion

cron php script safe_mode

jospBln

New Pleskian
hello,

I have a php script, which is working and executeable via shell, without any problem.

Now I want to run a cron on this script. But now I get the error:

Warning: copy(): SAFE MODE Restriction in effect. The script whose uid is 10004 is not allowed to access /home/httpd/vhosts owned by uid 0 in /home/httpd/vhosts/mydomain/httpdocs/get_tpl.php on line 9

So I turned off safe_mode with
<Directory /home/httpd/vhosts/mydomain/>
php_admin_value safe_mode 0
</Directory>

did a
/usr/local/psa/admin/bin/websrvmng -a

and a
rcapache2 restart

But it's still the same!
Where should I start?

thanks
Joerg
 
Turning off safe mode is not necessarily the best thing to do, but you should first remove the trailing / from the <Directory line:

<Directory /home/httpd/vhosts/mydomain>

and restart apache and test it again.

Does the script have to reside in the domain's docroot? An alternative would be to use phpsuexec to run the script. Whoops, nevermind about phpsuexec, just noticed you want to run from cron... From cron you should be able to run the script as root (uid=0). Put the script in root's cronjob list, not the domain user's.
 
hhmmm..... I deleted the slash, but it didn't help....

I still got
"The script whose uid is 10004 is not allowed to access /home/httpd/vhosts owned by uid 0 in /home/httpd/vhosts/mydomain/httpdocs/wm_include/get_tpl.php on line 9"

Why does the script want to access /home/httpd/vhosts ?

It just copies an html site via httpd to a local directory. And this directory is
/home/httpd/vhosts/mydomain/httpdocs/material

Do you have any idea?
 
First, uid=10004 is what user? The domain ftpuser? Have you made sure the ownership of the source and destination directories and script file are ftpusername : psacln (using chown). And that there are Read and Write permissions...

Does this error happen when you run the script as a cron job or are you currently running it from a site page?

Also, since the script is within the docroot, you aren't using hardcoded paths which reference /home/httpd/vhosts/... are you? If so, try using just /material, since / would be the domain's docroot.

I think I'm getting a bit lost on this... need sleep soon.
 
hey, thanks for your help! It was the path.

I had a relative path and needed the absolute path.

Thanks
Joerg
 
Back
Top