LinuxSir.cn,穿越时空的Linuxsir!

 找回密码
 注册
搜索
热搜: shell linux mysql
查看: 802|回复: 2

如何让mod_fcgid模块支持bash的cgi脚本?

[复制链接]
发表于 2011-11-6 17:24:45 | 显示全部楼层 |阅读模式
我使用的是apache,安装了mod_fcgid模块,现在perl与php脚本都可以运行,但是bash的脚本却无法运行,每次运行日志都显示500错误,请教一下大家,如何让bash能在mod_fcgid模块下作为cgi运行?


bash的CGI脚本,这个脚本是由apache提供的
  1. #!/bin/sh

  2. # disable filename globbing
  3. set -f

  4. echo "Content-type: text/plain; charset=iso-8859-1"
  5. echo

  6. echo CGI/1.0 test script report:
  7. echo

  8. echo argc is $#. argv is "$*".
  9. echo

  10. echo SERVER_SOFTWARE = $SERVER_SOFTWARE
  11. echo SERVER_NAME = $SERVER_NAME
  12. echo GATEWAY_INTERFACE = $GATEWAY_INTERFACE
  13. echo SERVER_PROTOCOL = $SERVER_PROTOCOL
  14. echo SERVER_PORT = $SERVER_PORT
  15. echo REQUEST_METHOD = $REQUEST_METHOD
  16. echo HTTP_ACCEPT = "$HTTP_ACCEPT"
  17. echo PATH_INFO = "$PATH_INFO"
  18. echo PATH_TRANSLATED = "$PATH_TRANSLATED"
  19. echo SCRIPT_NAME = "$SCRIPT_NAME"
  20. echo QUERY_STRING = "$QUERY_STRING"
  21. echo REMOTE_HOST = $REMOTE_HOST
  22. echo REMOTE_ADDR = $REMOTE_ADDR
  23. echo REMOTE_USER = $REMOTE_USER
  24. echo AUTH_TYPE = $AUTH_TYPE
  25. echo CONTENT_TYPE = $CONTENT_TYPE
  26. echo CONTENT_LENGTH = $CONTENT_LENGTH
复制代码
发表于 2011-11-6 21:25:58 | 显示全部楼层
#!/bin/bash
cat <<EOF
Content-Type:text/html
<pre>
My username is: $(id -un)
My id is: $(id -u)
My shell setting are:
$(set)
Here is the file in /tmp:
$(ls -l /tmp)
</pre>
EOF

保存为test.sh http://localhost/cgi-bin/test.sh 执行试试

我在RHEL 6.0 6.1中测试OK
回复 支持 反对

使用道具 举报

 楼主| 发表于 2011-11-7 08:54:27 | 显示全部楼层
不行,脚本是执行了,但是却没有将结果送到网页上,只是将结果输入到了日志里。

  1. # cat logs/error_log
  2. [Mon Nov 07 16:44:55 2011] [error] [client 172.16.3.119] File does not exist: /root/httpd-2.2.21-mods-shared/htdocs/favicon.ico
  3. [Mon Nov 07 16:45:17 2011] [error] [client 172.16.3.119] File does not exist: /root/httpd-2.2.21-mods-shared/htdocs/favicon.ico
  4. Content-Type:text/html
  5. <pre>
  6. My username is: daemon
  7. My id is: 2
  8. My shell setting are:
  9. BASH=/bin/bash
  10. BASHOPTS=cmdhist:extquote:force_fignore:hostcomplete:interactive_comments:progcomp:promptvars:sourcepath
  11. BASH_ALIASES=()
  12. BASH_ARGC=()
  13. BASH_ARGV=()
  14. BASH_CMDS=()
  15. BASH_LINENO=([0]="0")
  16. BASH_SOURCE=([0]="/root/httpd-2.2.21-mods-shared/fcgid/se.sh")
  17. BASH_VERSINFO=([0]="4" [1]="1" [2]="9" [3]="1" [4]="release" [5]="i686-pc-linux-gnu")
  18. BASH_VERSION='4.1.9(1)-release'
  19. DIRSTACK=()
  20. EUID=2
  21. GROUPS=()
  22. HOSTNAME=localhost
  23. HOSTTYPE=i686
  24. IFS=$' \t\n'
  25. LD_LIBRARY_PATH=/root/httpd-2.2.21-mods-shared/lib:
  26. MACHTYPE=i686-pc-linux-gnu
  27. OPTERR=1
  28. OPTIND=1
  29. OSTYPE=linux-gnu
  30. PATH=/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin:/opt/bin:/usr/i686-pc-linux-gnu/gcc-bin/4.4.5
  31. PPID=7339
  32. PS4='+ '
  33. PWD=/root/httpd-2.2.21-mods-shared/fcgid
  34. SHELL=/bin/false
  35. SHELLOPTS=braceexpand:hashall:interactive-comments
  36. SHLVL=1
  37. TERM=dumb
  38. UID=2
  39. _=/bin/bash
  40. Here is the file in /tmp:
  41. total 0
  42. -rw------- 1 daemon daemon 0 Nov  7 16:47 sh-thd-1320677763
  43. </pre>
  44. [Mon Nov 07 16:47:08 2011] [warn] [client 172.16.3.119] (104)Connection reset by peer: mod_fcgid: error reading data from FastCGI server
  45. [Mon Nov 07 16:47:08 2011] [error] [client 172.16.3.119] Premature end of script headers: se.sh
  46. [Mon Nov 07 16:47:08 2011] [error] [client 172.16.3.119] File does not exist: /root/httpd-2.2.21-mods-shared/htdocs/favicon.ico
复制代码
回复 支持 反对

使用道具 举报

您需要登录后才可以回帖 登录 | 注册

本版积分规则

快速回复 返回顶部 返回列表