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,并且不能提示输入密码,也就是不用验证密码即可。
使用bash写fastcgi程序时,一定要先输出Content-type和一个空行,不然nginx会报错502 Bad Gateway,后台访问日志中会有”upstream prematurely closed FastCGI stdout while reading response header from upstream”错误。
构建后在自动发布到tomcat7,因此这里选择”Deploy war/ear to a container”,然后选择tomcat7。WAR/EAR files填写相对于当前job的workspace目录的需要部署的文件的名字,比如build/libs/project.war。Context path输入自己想使用的访问路径,比如输入foo,则需要这样访问应用程序http://domain.tld/foo。其他字段为tomcat7的管理用户账号和访问tomcat7的URL。
用于tomcat7自动部署的管理用户必须具有manager-script角色,manager-gui角色是不够的,不然会有错误出现: The username you provided is not allowed to use the text-based Tomcat Manager (error 403)