A tough exec problem. please solve it...

Source: Internet
Author: User
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.

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.