A tough exec problem. please solve it ...... I am going to create a page for online programming and use the system to call exec to obtain the output value of the user-written program after running. the script written is basically as follows: PHPcode $ command & quot; varprogramuserprogram & quot; exec ($ command, $ data); print_r ($ data); (varp is a tough exec problem. please solve it ......
To create a page for online programming, you need to use the system to call exec to obtain the output value of the program you write after running. the script written is basically as follows:
PHP code
$command = "/var/program/userprogram";exec($command, $data);print_r($data);
(/Var/program/) is not the web root directory
This is simplified. after su to the apache user, run php test in the command line. php can successfully output the execution data of the program, but it is strange to access this file on the WEB that the Array ([0] => sh:/var/program/userprogram: permission denied ). I am wondering, the same code is okay on my own computer. I don't know if it is because of any security configuration that prevents the permission to execute non-system commands in other directories. In addition, I put the userprogram file under the web root directory, and it is okay to run it...
------ Solution --------------------
Change the chmod 777/var/program/userprogram command line
------ Solution --------------------
In linux, the executor permission is used for execution.
The apache process account permission is used in apache.
------ Solution --------------------
It is doubtful to use exec. To do this, it is estimated that c, sokcet, and so on will assist in the following.
------ Solution --------------------
Echo get_current_user ();
First, let's see what the currently running user is.
------ Solution --------------------
Permission problem: the permission of the apache account cannot execute that program.