Search code examples
phpubuntuchmoduser-permissionschown

Nginx/PHP-FPM exec another php script


This works, so exec function is not disabled.

exec('ls');

This doesn't work even thought script.php has 777 chmod.

exec('php script.php');

This doesn't work either.

exec('php -v');

I tried to chmod and chown /var/www/ folder, but it doesn't help. I suppose this is due to the www-data user permissions, looks like it doesn't have access to several bin files.

How can I solve this?


Solution

  • try

    which php 
    

    and then get the path and put it in exec() like

    exec("/opt/local/bin/php -v");