Untitled Post - 63

nginx fastcgi程序执行带有sudo命令的脚本时,前台报错”502 Bad Gateway”,后台日志中有错误记录”sudo: no tty present and no askpass program specified”,是因为nginx是以用户www-data来执行脚本的,而www-data用户默认是不在sudoers中的,并且执行脚本时没有tty,sudo也无法执行请求用户密码的程序,故有此提示。因此若要nginx可以执行使用sudo命令的CGI脚本,则必须将www-data加入sudoers,并且不能提示输入密码,也就是不用验证密码即可。