PHP executes exec in Linux

Source: Internet
Author: User
In Linux, PHP executes exec PHP version 5.4.

The PHP code is as follows:
   

Root users use php test. php on the server terminal
The output result is as follows, which is correct.
[root@localhost htdocs]# php test.phparray(1) {  [0]=>  string(4) "root"}


But enter the http://192.168.x.x/test.php in the browser
The output is empty.

I feel that it is a permission issue on the linux server, but I don't know which permission issue.
The user name for running httpd is apache.


Reply to discussion (solution)

Whoami display login name
The viewer accesses the website anonymously (that is, without a name), so it is correct to display it as null.

Whoami display login name
The viewer accesses the website anonymously (that is, without a name), so it is correct to display it as null.



Change to exec ('date', $ r);. I think it is a permission issue. Disable_functions in php. ini does not have a disabled function.

Output the error and you will know if the permission is incorrect.

Output the error and you will know if the permission is incorrect.



In apache access. log, only get requests exist.
There is no error in apache error. log.


Output the error and you will know if the permission is incorrect.



In apache access. log, only get requests exist.
There is no error in apache error. log.



Please open the php error output



Output the error and you will know if the permission is incorrect.



In apache access. log, only get requests exist.
There is no error in apache error. log.



Please open the php error output



Is error output display_errors in php. ini?
If yes, display_errors is already on

No errors
Then you can give chmod 777
Both whoami and date can output results in the browser.
I have tested it in linux. I think you are more inclined to select the latter for the remaining two characters and permissions...

No errors
Then you can give chmod 777
Both whoami and date can output results in the browser.
I have tested it in linux. I think you are more inclined to select the latter for the remaining two characters and permissions...



Can I change test. php to 777? It is useless after the change, no matter whether I change the ownership of test. php to apache or root.
-Rwxrwxrwx. 1 root 38 Jul 10 16:14 test. php


No errors
Then you can give chmod 777
Both whoami and date can output results in the browser.
I have tested it in linux. I think you are more inclined to select the latter for the remaining two characters and permissions...



Can I change test. php to 777? It is useless after the change, no matter whether I change the ownership of test. php to apache or root.
-Rwxrwxrwx. 1 root 38 Jul 10 16:14 test. php


What about directory permissions? I can't think of any other things. what kind of Linux do you test? everything is fine in Ubuntu...

Tested, everything works.

My environment is:
Centos 1, 6.5
Python 5.4
In Apache 2.4

The user name (group) for executing Apache httpd is not a logged-on apache: apache

Nginx
Python 5.3
No output

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.