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

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...

Not receiving some emails

Posted by Kain, 12-20-2007, 07:09 AMI've got a weird one here. A client is not receiving some...

ASP.net vs PHP

Posted by porov, 03-01-2007, 03:06 AMWhat is better? I hear asp.net is better for large scale...

[HELP]Need Script for manual Cookie Deleting

Posted by kohkindachi, 09-12-2008, 09:37 AMHey guys, I need a few codings(php; javascript or etc)...

Unable to import mysql database

Posted by bambinou, 10-29-2012, 06:08 AMHello, I have exported a mysqwl database from a cpanel...