PHP在Linux下执行exec
PHP的版本为5.4
PHP代码如下:
<?phpexec('whoami', $r);var_dump($r);
root用户在服务器终端使用php test.php
输出结果如下,是正确的
[root@localhost htdocs]# php test.phparray(1) { [0]=> string(4) "root"}
但是在浏览器上输入http://192.168.x.x/test.php
输出为空。
感觉是linux服务器上的权限问题,但是又不知道哪个权限问题。
运行httpd的用户名为apache
回复讨论(解决方案)
whoami 显示登录名
浏览者是匿名(就是没有名字)访问网站的,所以显示为空是正确的
whoami 显示登录名
浏览者是匿名(就是没有名字)访问网站的,所以显示为空是正确的
改成exec('date', $r);也一样,我感觉是权限问题。在php.ini中的disable_functions不存在一个被禁用的函数
把错误输出 你就知道是不是权限问题了.
把错误输出 你就知道是不是权限问题了.
apache的access.log中,只有get请求。
apache的error.log中,没有错误产生。
把错误输出 你就知道是不是权限问题了.
apache的access.log中,只有get请求。
apache的error.log中,没有错误产生。
请打开 php 的错误输出
把错误输出 你就知道是不是权限问题了.
apache的access.log中,只有get请求。
apache的error.log中,没有错误产生。
请打开 php 的错误输出
错误输出是指php.ini中的 display_errors吗?
如果是的话,display_errors 已经 on
没有错误的话
那么你就chmod 吧 给个777
无论是 whoami 还是date 都是可以输出结果的 在浏览器下
我在linux 下实测过了.剩下两个 人品和 权限 我想你应该更倾向于选择后者吧...
没有错误的话
那么你就chmod 吧 给个777
无论是 whoami 还是date 都是可以输出结果的 在浏览器下
我在linux 下实测过了.剩下两个 人品和 权限 我想你应该更倾向于选择后者吧...
把上面的test.php改成777吗?改后还是没用,不管我把test.php的所有权改在apache还是root
-rwxrwxrwx. 1 root root 38 Jul 10 16:14 test.php
没有错误的话
那么你就chmod 吧 给个777
无论是 whoami 还是date 都是可以输出结果的 在浏览器下
我在linux 下实测过了.剩下两个 人品和 权限 我想你应该更倾向于选择后者吧...
把上面的test.php改成777吗?改后还是没用,不管我把test.php的所有权改在apache还是root
-rwxrwxrwx. 1 root root 38 Jul 10 16:14 test.php
目录权限呢?都改改看看吧 想不出来还有什么其他的,你在什么Linux 下测试的,我在Ubuntu 下 一切都好...
测试过,一切正常。
我的环境是:
Centos 6.5
PHP 5.4
Apache 2.4
Apache httpd的执行用户名(组)为非登录的apache:apache
nginx
php 5.3
表示也没有输出

Hot AI Tools

Undresser.AI Undress
AI-powered app for creating realistic nude photos

AI Clothes Remover
Online AI tool for removing clothes from photos.

Undress AI Tool
Undress images for free

Clothoff.io
AI clothes remover

AI Hentai Generator
Generate AI Hentai for free.

Hot Article

Hot Tools

Notepad++7.3.1
Easy-to-use and free code editor

SublimeText3 Chinese version
Chinese version, very easy to use

Zend Studio 13.0.1
Powerful PHP integrated development environment

Dreamweaver CS6
Visual web development tools

SublimeText3 Mac version
God-level code editing software (SublimeText3)

Hot Topics



JWT is an open standard based on JSON, used to securely transmit information between parties, mainly for identity authentication and information exchange. 1. JWT consists of three parts: Header, Payload and Signature. 2. The working principle of JWT includes three steps: generating JWT, verifying JWT and parsing Payload. 3. When using JWT for authentication in PHP, JWT can be generated and verified, and user role and permission information can be included in advanced usage. 4. Common errors include signature verification failure, token expiration, and payload oversized. Debugging skills include using debugging tools and logging. 5. Performance optimization and best practices include using appropriate signature algorithms, setting validity periods reasonably,

Static binding (static::) implements late static binding (LSB) in PHP, allowing calling classes to be referenced in static contexts rather than defining classes. 1) The parsing process is performed at runtime, 2) Look up the call class in the inheritance relationship, 3) It may bring performance overhead.

What are the magic methods of PHP? PHP's magic methods include: 1.\_\_construct, used to initialize objects; 2.\_\_destruct, used to clean up resources; 3.\_\_call, handle non-existent method calls; 4.\_\_get, implement dynamic attribute access; 5.\_\_set, implement dynamic attribute settings. These methods are automatically called in certain situations, improving code flexibility and efficiency.

Using python in Linux terminal...

Regarding the problem of removing the Python interpreter that comes with Linux systems, many Linux distributions will preinstall the Python interpreter when installed, and it does not use the package manager...

Multithreading in the language can greatly improve program efficiency. There are four main ways to implement multithreading in C language: Create independent processes: Create multiple independently running processes, each process has its own memory space. Pseudo-multithreading: Create multiple execution streams in a process that share the same memory space and execute alternately. Multi-threaded library: Use multi-threaded libraries such as pthreads to create and manage threads, providing rich thread operation functions. Coroutine: A lightweight multi-threaded implementation that divides tasks into small subtasks and executes them in turn.

In PHP8, match expressions are a new control structure that returns different results based on the value of the expression. 1) It is similar to a switch statement, but returns a value instead of an execution statement block. 2) The match expression is strictly compared (===), which improves security. 3) It avoids possible break omissions in switch statements and enhances the simplicity and readability of the code.

To open a web.xml file, you can use the following methods: Use a text editor (such as Notepad or TextEdit) to edit commands using an integrated development environment (such as Eclipse or NetBeans) (Windows: notepad web.xml; Mac/Linux: open -a TextEdit web.xml)
