在Linux环境中,apache是以apache用户的身份(或者nobody)来运行的,因此不少的外部程序,没有相应的权限。直接sudo的话,须要输入密码,因此必须将apache(或者nobody)加入到sudo里面的nopassword的列表里面。具体的作法以下: visudo(不要本身去修改sudoers文件,这样有可能改错,visudo会帮助纠正错误) 在里面补充: %nobody ALL=NOPASSWD:/bin/rar %apache ALL=NOPASSWD:/bin/rar 那么就能够执行/bin/rar指令了,若是不补充NOPASSWD参数,那么会出现以下的提示信息(这些提示信息会出如今console里面,固然前提是你修改了/etc/passwd里面的apache(nobody)的login shell为bash以后,su apache过去,才可能见到的): We trust you have received the usual lecture from the local System Administrator. It usually boils down to these three things: #1) Respect the privacy of others. #2) Think before you type. #3) With great power comes great responsibility. Password: