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

Помог ли вам данный ответ?

 Распечатать статью

Также читают

Managed server

Posted by jamesthorpe, 06-25-2008, 07:14 PMHey guys, I am having some problems with a server...

Stop spammers from spoofing my email domain?

Posted by mifbody, 05-04-2007, 06:55 AMIs there any way to stop spammers from spoofing my...

Own a Server? (Remove Fantastico now)

Posted by BitSurFer, 04-30-2007, 08:31 PMHello EveryOne If you have Fantastico installed in your...

MySQL error code: 2006

Posted by Glostar, 04-18-2009, 03:54 AMI update MySQL from version 4 to 5.0.67-community. Now, I...

PHP Sessions

Posted by raulgonzalez, 09-12-2008, 10:57 AMHello, I downloaded a script for our company....