I am trying to use the shell_exec() function on PHP to install a package with apt. To do so, I've figured that I will also need the -y operator to assume yes to all questions. So I have got:
$output = shell_exec("apt-get -y install <package-id>");
echo $output;
However, by doing this, the install only manages to output up to the "After this operation, 0B of additional disk space will be used" point and doesn't return an error. When running this from the terminal however, it runs perfectly. Also, shell_exec is running from root. So is this a problem with my PHP server configuration, or something else? Thanks.
Edit: I forgot to mention to mention that the PHP is running through lighttpd which could be causing the issue. Also I have figured that using apt-get install
actually downloads the .deb but fails to install it without giving an error. From this, I've concluded that it's something to do with permissions, but I haven't figured out how to fix it. Thanks.