centos-php return 127 error code when executing linux command with exec

Source: Internet
Author: User
The server CentOS, because it needs to call PHANTOMJS, has installed the PHANTOMJS binaries, and, on Putty, tried PHANTOMJS--version to output normally: 1.9.8.
Then try the following:

exec("phantomjs --version", $o, $e);echo $e;//返回127

Very puzzled, and tried again:

exec("ls", $o, $e);echo $e;//还是返回127

Google for a long time, some people said to use the absolute path, then try again:

#which ls/bin/ls

Then, in PHP, enter:

exec("/bin/ls", $o, $e);echo $e;//还是返回127

View Php.ini,safe_mode=off,disble_functions also did not disable the exec () and system () and other functions, supposedly PHP should have to execute EXEC permissions Ah, replaced by System (), Shell_ EXEC is return 127, I'm going crazy, ask the big God answer, this exec function exactly the miscellaneous

Reply content:

The server CentOS, because it needs to call PHANTOMJS, has installed the PHANTOMJS binaries, and, on Putty, tried PHANTOMJS--version to output normally: 1.9.8.
Then try the following:

exec("phantomjs --version", $o, $e);echo $e;//返回127

Very puzzled, and tried again:

exec("ls", $o, $e);echo $e;//还是返回127

Google for a long time, some people said to use the absolute path, then try again:

#which ls/bin/ls

Then, in PHP, enter:

exec("/bin/ls", $o, $e);echo $e;//还是返回127

View Php.ini,safe_mode=off,disble_functions also did not disable the exec () and system () and other functions, supposedly PHP should have to execute EXEC permissions Ah, replaced by System (), Shell_ EXEC is return 127, I'm going crazy, ask the big God answer, this exec function exactly the miscellaneous

Check the user who is currently running the PHP script
I tested it with the root user, there's nothing wrong with that.
exec or System Run command, the first should be the current run script user has 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.