enabling shell_exec() for some user

Posted by dendis, 03-26-2008, 08:24 PM
Hi all, I need to run one PHP script from crontab as root.. But my basic PHP has shell_exec disabled in php.ini and when trying to run script that use shell_exec even from root I get error that function is disabled. Do you have any suggestion how can I overcome this and have ability to use this function when executing php script from console ? Thanks!

Posted by SPaReK, 03-26-2008, 08:52 PM
Copy your server-wide php.ini to a different folder: cp /usr/local/lib/php.ini /root (These are just examples, I don't know what the real path to your php.ini file is and you can choose a different destination path, it doesn't matter) Now edit the php.ini file that you just copied to the new destination vi /root/php.ini and remove shell_exec from the disable_function list. Now when running the PHP script from the command line and from your cron use something like: php -c /root/php.ini /path/to/php/script.php

Posted by supportmatrix, 03-27-2008, 02:03 AM
Yes, that is the correct method. It will work

Posted by dendis, 03-28-2008, 09:12 AM
Thanks it works fine. I also found another way how to run it - just type php -n yourscript.php and it will run without php.ini and without functions disabled

Was this answer helpful?

 Print this Article

Also Read

Ioncube on server?

Posted by vito, 01-11-2008, 03:42 PMWhat command line entry do I use to find out if I have...

I doubt anyone can help, but here goes....

Posted by worldveil, 09-12-2007, 11:04 PMHi all, I doubt that anyone can solve this, but here...

Redrect - make it impossible to trace source

Posted by ntesla123, 02-10-2011, 08:51 PMHow do I make a redirect that would redirect someone to...

/home/ privacy

Posted by Weedy, 04-14-2009, 09:19 AMHow do I keep users from spying on each others files? If I...

partition disk (/) 80% full - need advice

Posted by activa, 09-12-2007, 08:52 PMhello all . i have the partition (/) 80% full ; what...