Skip to content
Advertisement

Can’t Execute a PHP file via HTTP

Here is a command I successfully execute in terminal:

PHP process_scan.php

I want to execute that code every time a user visits a file, which exists in the same directory as the file mentioned in the command.

Here is the code in the file:

exec('PHP process_scan.php 2>&1', $output, $retval);

Running the file in the browser, $retval = 127 wit $output = "sh: PHP: command not found".

How can I successfully run the command every time a user visits the file?

Advertisement

Answer

Instead of referencing PHP, I got this to work by executing PHP bin file:

exec('/usr/bin/php process_scan.php 2>&1', $output, $retval);
User contributions licensed under: CC BY-SA
1 People found this is helpful
Advertisement