Notes for calling Shell scripts in PHP

Source: Internet
Author: User
Php calls the svnup. php file of the shell script :? Set_time_limit (0); $ outputarray (); $ ret0; exec (usrbinsudodata0shellsvnvp. sh, $ output, $ ret); echoResult: {$ ret}; print_r ($ output );? Data0shellsvnvp. sh is an updated script. The main content is sv.

PhpThe content of the svnup. php file that calls the shell script:

Set_Time_ Limit (0 );
// $ Output = array ();
$ Ret = 0;
ExEc ("/usr/bin/SuDo/data0/shell/svnvp. sh ", $ output, $ ret );
Echo "Result: {$ ret }";
Print_r ($ output );
?>

/Data0/shell/svnvp. sh is an update script. The main content is svn up.

You also need to modify the sudo configuration file, such as mongodoCommandEdit the configuration file:

1. Comment Defaults requiretty
Defaults requiretty is changed to # Defaults requiretty, indicating that the terminal does not need to be controlled.
Otherwise sudo: sorry, you must have a tty to run sudo

2. Add Defaults visib1_w
Otherwise, sudo: no tty present and no askpass program specifi will appear.Ed

I found that sudo-1.6.9p17-5.el5 does not support this parameter, sudo-1.7.2p1-10.el5 supports.


3. Grant the www user the svn execution permission
For example, add www ALL = (ALL) NOPASSWD:/data0/shell/svnvp. sh
Note: NOPASSWD eliminates the need to enter the password of the www user during command execution.

Www users are nginx or apache running users

4. Restart nginx or apache to allow users to regain permissions.

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.