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