Home >Backend Development >PHP Tutorial >Executing php exec system shell_exec has no results? Done in one article!

Executing php exec system shell_exec has no results? Done in one article!

藏色散人
藏色散人forward
2022-11-22 16:33:047101browse

This article will introduce to you the problem that php exec system shell_exec cannot be executed. The main content is to explain the method of executing php exec() system() shell_exec() without results and the result is NULLD. I hope it will be helpful to friends in need~

Executing php exec system shell_exec has no results? Done in one article!

php exec() system() shell_exec() cannot be executed, there is no result, the result is NULLD, solution

The code index.php on the server:

8dd35a9bb6694d18fe2e705a52c40454'    
var_dump($arr);

After the browser is accessed, the printed result is: NULL

It means that the server has not turned on PHP and used exec(); [Recommended learning: PHP video Tutorial

Solution:

1. Add a function to view the currently running user:

6783dc79d460790f46c82eb82ede8dfb'    
var_dump($arr);

Display: root

2. Go to the server to modify file permissions:

$ chmod 777 index.php

View the user and permissions of index.php:

$ ll

Result:

-rwxrwxrwx 1 root root    1595 Sep 20 10:18 index.php

3. Check php.ini to see if these functions are disabled:

$ cd /usr/local/php/etc
$ vim php.ini

##Find disable_functions =


Remove exec, system, and exec_shell and use whichever one you use;

4. Restart the php service. This step is very important:

$ /etc/init.d/php-fpm restart
Then test, the browser accesses the server and the result is:

Most of it is because php.ini disables the exec function and the execution permission of the file.

The above is the detailed content of Executing php exec system shell_exec has no results? Done in one article!. For more information, please follow other related articles on the PHP Chinese website!

Statement:
This article is reproduced at:cnblogs.com. If there is any infringement, please contact admin@php.cn delete