When centos-php uses exec to execute Linux commands, the error code 127 is returned.

Source: Internet
Author: User
Tags centos server
The centos server has installed the phantomjs binary file because it needs to call phantomjs. In addition, it has tried to output phantomjs -- version on putty: 1.9.8. then I tried: {code ...} wondering, try again: {code ...} google for a long time, some people... the centos server has installed the phantomjs binary file because it needs to call phantomjs. In addition, it has tried to output phantomjs -- version on putty: 1.9.8.
Then I tried:

Exec ("phantomjs -- version", $ o, $ e); echo $ e; // 127 is returned.

Wondering, try again:

Exec ("ls", $ o, $ e); echo $ e; // still returns 127

Google has been around for a long time. Some people say they want to adopt an absolute path. Then they try again:

#which ls/bin/ls

Then input the following in php:

Exec ("/bin/ls", $ o, $ e); echo $ e; // returns 127

View php. ini, safe_mode = Off, and the exec () and system () functions are not disabled in disble_functions. It is reasonable to say that php should have the permission to execute exec and change it to system (), all shell_exec returns 127. I am crazy. Please help me solve this. The exec function should be used in all cases.

Reply content:

The centos server has installed the phantomjs binary file because it needs to call phantomjs. In addition, it has tried to output phantomjs -- version on putty: 1.9.8.
Then I tried:

Exec ("phantomjs -- version", $ o, $ e); echo $ e; // 127 is returned.

Wondering, try again:

Exec ("ls", $ o, $ e); echo $ e; // still returns 127

Google has been around for a long time. Some people say they want to adopt an absolute path. Then they try again:

#which ls/bin/ls

Then input the following in php:

Exec ("/bin/ls", $ o, $ e); echo $ e; // returns 127

View php. ini, safe_mode = Off, and the exec () and system () functions are not disabled in disble_functions. It is reasonable to say that php should have the permission to execute exec and change it to system (), all shell_exec returns 127. I am crazy. Please help me solve this. The exec function should be used in all cases.

Check your current PHP script user
I tested it with the root user. There is no error.
Exec or system commands should first be run by the script user with the permission to execute this program.

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.