Home >Backend Development >PHP Problem >What should I do if php cannot call linux commands?

What should I do if php cannot call linux commands?

藏色散人
藏色散人Original
2021-05-17 11:05:581766browse

How to solve the problem that php cannot call linux commands: 1. Turn off selinux; 2. Add the apache user in the httpd.conf configuration file to use all commands; 3. Modify the default permissions for starting apache.

What should I do if php cannot call linux commands?

The operating environment of this article: linux5.9.8 system, PHP7.1 version, DELL G3 computer

php cannot call the linux command: authorization denied or The audit interface cannot be opened

1. Close selinux

Method

a. Quickly close SElinux. Use the following command:

  /usr/sbin/setenforce 0 立刻关闭 SELINUX
  /usr/sbin/setenforce 1 立刻启用 SELINUX

b. Add to The system starts by default

  echo "/usr/sbin/setenforce 0" >> /etc/rc.local

c. You can edit the configuration file to achieve the same purpose

     vi /etc/selinux/conf
     set SELINUX=disabled

2. Add the apache user to the httpd.conf configuration file to use all commands without a password

disable_functions= in the php.ini file cancels restrictions on related functions

3. Modify the default permissions for starting apache

Method

a, Modification

        vi /etc/passwd
  vi /etc/group
        vi/etc/sudoers

b. Add the apache user to the corresponding file/folder owner chown user.group FoldersName

Modify permissions chmod 775 Foldersname

Recommended learning: "PHP video tutorial

The above is the detailed content of What should I do if php cannot call linux commands?. For more information, please follow other related articles on the PHP Chinese website!

Statement:
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