Home > Backend Development > PHP Tutorial > PHP在Linux下执行exec解决方案

PHP在Linux下执行exec解决方案

WBOY
Release: 2016-06-13 12:01:46
Original
1680 people have browsed it

PHP在Linux下执行exec
PHP的版本为5.4

PHP代码如下:

<br /><?php<br />exec('whoami', $r);<br />var_dump($r);<br />
Copy after login


root用户在服务器终端使用php test.php
输出结果如下,是正确的
<br />[[email&#160;protected] htdocs]# php test.php<br />array(1) {<br />  [0]=><br />  string(4) "root"<br />}<br />
Copy after login


但是在浏览器上输入http://192.168.x.x/test.php
输出为空。

感觉是linux服务器上的权限问题,但是又不知道哪个权限问题。
运行httpd的用户名为apache
------解决方案--------------------
whoami 显示登录名
浏览者是匿名(就是没有名字)访问网站的,所以显示为空是正确的

------解决方案--------------------
把错误输出 你就知道是不是权限问题了.

Related labels:
source:php.cn
Statement of this Website
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn
Popular Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template