In addition to Weibo, there is also WeChat
Please pay attention
WeChat public account
Shulou
2025-01-18 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Development >
Share
Shulou(Shulou.com)06/01 Report--
Today, I will introduce to you how to solve the problem of php exec error reporting. The content of the article is good. Now I would like to share it with you. Friends who feel in need can understand it. I hope it will be helpful to you. Let's read it along with the editor's ideas.
Php exec error solution: 1, modify the ping or the corresponding command execution permissions; 2, the command full path completion "exec ('/ usr/sbin',$output);"; 3, add the target directory in the environment variable.
This article operating environment: Windows7 system, PHP7.1 version, DELL G3 computer
How to solve the problem of php exec error reporting?
The exec () function in PHP failed to execute the system command. 0. Description
In php, we can use exec () to execute system commands, but sometimes we encounter situations where the execution of the exec () command is unsuccessful or there is no return, so let's explain this:
1. Function exec (string $command [, array & $output [, int & $return_var]]): string parameter description: the command to be executed by 1.$command 2.$output execution result 3.$return_var if both $output and this variable are set, the return status of the command execution will be written to this variable 2. Example exec ("ping www.baidu.com", $output)
Normally, the execution result is no different from executing ping directly on the server, but it can lead to unexpected conditions due to some reasons. Here are two explanations and solutions.
2.1 permission issues
problem
When we execute the linux system command directly on the server (in this case, ping), the execution permission depends on the permission of our login user. If the login user is root, we use root to execute ping. But when we visit the website, our user at this time is www, if we do not modify the execution permissions of ping, it will not be able to execute successfully.
Solve
Modify the execution permission of ping or corresponding command 2.2 Command path problem
problem
In another case, when we execute a command with exec, we do not report an error or return a result, because the command is not in the directory where the environment variable is configured, that is, in the / etc/profile file. Taking ifconfig as an example, we can use whereis ifconfig to find out the specific path of the command, such as the path under / usr/sbin. There are two solutions:
Solve
1 copy the command to / usr/bin, that is, the directory under the environment variable (not recommended)
2 directly complete the full path of the command exec ('/ usr/sbin',$output); (recommended)
3 adding the target directory in the environment variables such as adding / usr/sbin to the directory is all the contents of how to solve the php exec error problem, more content related to how to solve the php exec error problem can search the previous article or browse the following article to learn ha! I believe the editor will add more knowledge to you. I hope you can support it!
Welcome to subscribe "Shulou Technology Information " to get latest news, interesting things and hot topics in the IT industry, and controls the hottest and latest Internet news, technology news and IT industry trends.
Views: 0
*The comments in the above article only represent the author's personal views and do not represent the views and positions of this website. If you have more insights, please feel free to contribute and share.
Continue with the installation of the previous hadoop.First, install zookooper1. Decompress zookoope
"Every 5-10 years, there's a rare product, a really special, very unusual product that's the most un
© 2024 shulou.com SLNews company. All rights reserved.