Reputation: 2143
I have one file with code
shell_exec (php test.php)
When I run this file from command prompt, It run successfully and when same file I am trying to run through web browser this will give error as
sh: php command not found.
what can be the issue?
Upvotes: 0
Views: 2176
Reputation: 2143
Problem was with php path. so I have done like this
if(defined('PHP_BINARY') && PHP_BINARY)
{
$path = PHP_BINARY . '/php'; //PHP >= 5.4
}
else if(defined('PHP_BINDER') && PHP_BINDER)
{
$path = PHP_BINDER . '/php'; //PHP < 5.4
}
else
{
//Throws Exception
}
and then used this variable in shell command as
shell_exec ($path test.php)
Upvotes: 1
Reputation: 873
could you please provide the information which webserver you're using ? If you are using apache you might install libapache2-mod-php7.0 for php7.
ToDo this apt comes in handy:
apt-get install libapache2-mod-php7.0
or try to activate it
sudo a2enmod php7.0
Make sure that the php files are marked executable for webserver user (e.g. www-data)
sudo chmod -R o+x *.php
Upvotes: 0