PHP does not have permission to call Linux commands)

Source: Internet
Author: User
Let's take a look at how PHP does not have the permission to call Linux commands. I hope the article will help you. business Background: yourcmd is my linux program. it has strict permission requirements. when using php to execute yourcmd... let's take a look at how PHP does not have the permission to call Linux commands. I hope the article will help you.

Business background:Yourcmd is my linux program, which has strict permission requirements. when using php to execute yourcmd program

System:CentOS 1, 6.3

Apache is the execution user of php.

Execute the program/usr/local/yourcmd/sbin/yourcmd on linux using the exec function

The php code is as follows:

 

The test result shows no permission.

Array ([0] => sudo: no tty present and no askpass program specified)

Solution:

$ Mongodo

1) comment out the following lines:

#Defaults    requiretty

2) add the following to the end of the file:

apache ALL=(ALL) NOPASSWD: ALLCmnd_Alias yourcmd = /usr/local/yourcmd/sbin/yourcmd

Test result:

Array ( [0] => Warning: memory is too small: 1044725760 [1] => test configure is ok )


Article link:

Save this article for favorites!

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.