【问题标题】:Execute CGI file without extension执行不带扩展名的 CGI 文件
【发布时间】:2017-08-30 02:01:20
【问题描述】:

我是 CGI 或 Apache 的新手。

我正在尝试安装一个名为 mooshak 的应用程序。

安装正常。但是当我打开本地站点时,它只是下载文件而不是执行它。

当我打开http://localhost/~mooshak/cgi-bin/execute 时,它只是下载文件,如下所示:

#!/bin/sh
# the next line restarts using tclsh \
PATH=$PATH:/usr/local/bin:/usr/contrib/bin  ; exec tclsh "$0" "$@"

#-*-Mode: TCL; iso-accents-mode: t;-*-  

set errorCode NONE

cd ../..

lappend auto_path packages

source .config

execute::command_line

我的/etc/apache2/mods-enabled/userdir.conf 文件如下所示:

<IfModule mod_userdir.c>
        <Directory /home/*/public_html/cgi-bin>
                Options +ExecCGI -Includes -Indexes
                SetHandler cgi-script
                Order allow,deny
                Allow from all
        </Directory>
</IfModule>

我该怎么办?

【问题讨论】:

    标签: linux apache tcl cgi


    【解决方案1】:

    这样试试

    <Directory /home/*/public_html>
             Options -Includes -Indexes
             Order allow,deny
             Allow from all
    </Directory>
    <Directory /home/*/public_html/cgi-bin>
             Options +ExecCGI -Includes -Indexes
             SetHandler cgi-script
    </Directory>
    

    并给脚本chmod +x

    【讨论】:

      【解决方案2】:

      尝试将/urs/lib/cgi-bin 用于 cgi 脚本。如果您不知道该怎么做,其他任何事情都会让您头疼。

      cgi-scripts 需要对用户www-data可执行可读

      对于 Apache 版本 >=2.2,您需要在 /etc/apache2/conf-available 中添加一个条目。我的配置看起来像这样......

      admin@suse:~$ cat /etc/apache2/conf-available/cgi-bin.conf 
      <IfModule mod_alias.c>
          <IfModule mod_cgi.c>
              Define ENABLE_USR_LIB_CGI_BIN
          </IfModule>
      
          <IfModule mod_cgid.c>
              Define ENABLE_USR_LIB_CGI_BIN
          </IfModule>
      
          <IfDefine ENABLE_USR_LIB_CGI_BIN>
              ScriptAlias /cgi-bin/ /usr/lib/cgi-bin/
              <Directory "/usr/lib/cgi-bin">
                      Options +ExecCGI -MultiViews +SymLinksIfOwnerMatch
                  AllowOverride AuthConfig
                      AuthType Basic
                      AuthName "Suleiman's Heimat 2.0"
                      AuthBasicProvider file
                      AuthUserFile /etc/apache2/passwd
                      Require valid-user
              </Directory>
          </IfDefine>
      </IfModule>
      

      这些是 Debian 系统的默认设置,以及额外的密码保护。

      然后你打电话给a2enconf cgi-bin

      这与/etc/apache2/mods-enabled 无关!我找不到将 cgi-code 放在那里的理由。相反,您需要通过

      激活公共网关接口
      a2enmod cgi
      

      这会将一个条目放入/etc/apache2/mods-enabled

      最后,你需要通过/etc/init.d/apache2 restart重启服务器

      你去吧。
      希望这会有所帮助。


      加法

      在重新启动服务器之前,您应该运行apache2ctl configtest 来检查您的配置!

      /var/log/apache2/ 也有很好的信息,当事情向南时。
      您也可以使用命令systemctl status apache2.service 来检查您的服务的状态,并使用journalctl -b -n 30 -u apache2.service 来获取最后30 个协议条目。

      【讨论】:

        猜你喜欢
        • 2015-09-04
        • 1970-01-01
        • 2015-03-11
        • 1970-01-01
        • 2011-06-15
        • 2018-01-11
        • 2011-10-02
        • 1970-01-01
        • 2015-05-13
        相关资源
        最近更新 更多