【问题标题】:Apache 2.4.7 403 Forbidden ErrorApache 2.4.7 403 禁止错误
【发布时间】:2014-07-16 22:10:24
【问题描述】:

我正在尝试使用 apache (http://wiki.openstreetmap.org/wiki/Overpass_API/install) 将 overpass api 安装为 Web 服务器

这是我的 000-default.conf

<VirtualHost *:80>
ServerAdmin webmaster@localhost
ExtFilterDefine gzip mode=output cmd=/bin/gzip
DocumentRoot /root/osm-3s_v0.7.4/html

# This directive indicates that whenever someone types http://www.mydomain.com/api/ 
# Apache2 should refer to what is in the local directory [YOUR_EXEC_DIR]/cgi-bin/
ScriptAlias /api/ /srv/osm3s/cgi-bin/


# This specifies some directives specific to the directory: [YOUR_EXEC_DIR]/cgi-bin/
<Directory "/srv/osm3s/cgi-bin/">
            AllowOverride None
            Options +ExecCGI -MultiViews +SymLinksIfOwnerMatch
            Order allow,deny
            Allow from all
            #SetOutputFilter gzip
            #Header set Content-Encoding gzip
</Directory>

ErrorLog /var/log/apache2/error.log

# Possible values include: debug, info, notice, warn, error, crit, alert, emerg
LogLevel warn

CustomLog /var/log/apache2/access.log combined

但是当我尝试运行命令时:

http://175.33.148.57/api/interpreter?data=%3Cprint%20mode=%22body%22/%3E

我收到 403 Forbidden 错误。

我已经做了

chmod 777 /srv/osm3s/cgi-bin/

但似乎没有任何效果。

请帮忙,我已经坚持了 3 天了!提前致谢。

【问题讨论】:

  • 状态错误代码 403 forbidden 不是文件系统访问冲突。这是违反授权的。请检查您的目录是否有.htaccess 文件。
  • DocumentRootDirectory不应该是同一个文件夹吗?
  • 我认为它没有 .htaccess 文件,我还没有看到位于服务器上的文件。它应该在哪里/它看起来像什么声音?我认为文件目录不需要与我要访问的静态 html 相同,它是位于 /srv/osm3s/cgi-bin/ 中的名为“解释器”的文件
  • interpreter 文件是否可读可执行? selinux 是否处于强制模式?如果selinux 正在强制执行,请确保允许apache 访问该文件夹并允许读取和执行interpreter 文件。
  • 看来你需要SetHandlerSetHandler cgi-script

标签: apache ubuntu http-status-code-403


【解决方案1】:
try this as it is. don't add Order allow,deny or others

AddHandler cgi-script .cgi .py 
ScriptAlias /cgi-bin/ /usr/lib/cgi-bin/
<Directory "/usr/lib/cgi-bin">
    AllowOverride None
    Options +ExecCGI -MultiViews +SymLinksIfOwnerMatch
    Require all granted
    Allow from all
</Directory>

【讨论】:

    【解决方案2】:

    以下是我为可能有类似问题的任何人解决此问题的方法:

    问题似乎来自我安装立交桥的位置 ($EXEC_DIR)。

    所以我不得不将安装目录更改为:

    $EXEC_DIR       /var/www/osm/
    $DB_DIR         /var/www/osm/db/
    $PLANET_FILE    /var/www/osm/planet.osm.bz2
    $REPLICATE_DIR  /var/www/osm/rep/
    

    给出结果default.conf

    <VirtualHost *:80>
        ServerAdmin webmaster@localhost
        ExtFilterDefine gzip mode=output cmd=/bin/gzip
        DocumentRoot /root/osm-3s_v0.7.4/html
    
        # This directive indicates that whenever someone types                         http://www.example.com/api/ 
        # Apache2 should refer to what is in the local directory         [YOUR_EXEC_DIR]/cgi-bin/
        ScriptAlias /api/ /var/www/osm/cgi-bin/
    
    
        # This specifies some directives specific to the directory: [YOUR_EXEC_DIR]/cgi-bin/
        <Directory "/var/www/osm/cgi-bin/">
                AllowOverride None
                Options +ExecCGI -MultiViews +SymLinksIfOwnerMatch
                Order allow,deny
                Allow from all
                #SetOutputFilter gzip
                #Header set Content-Encoding gzip
        </Directory>
    
        ErrorLog /var/log/apache2/error.log
    
        # Possible values include: debug, info, notice, warn, error, crit, alert, emerg
        LogLevel warn
    
        CustomLog /var/log/apache2/access.log combined
    
    </VirtualHost>
    

    我试了又试,但无法让它与旧目录一起使用。祝你好运!

    【讨论】:

      【解决方案3】:

      替换: 允许所有人 经过 要求全部授予

      <Directory /www/mysite>
          Allow from All
      </Directory>
      
      <Directory /www/mysite>
          Require all granted
      </Directory>
      

      【讨论】:

        猜你喜欢
        • 1970-01-01
        • 1970-01-01
        • 1970-01-01
        • 2013-08-29
        • 2013-10-17
        • 1970-01-01
        • 1970-01-01
        • 1970-01-01
        相关资源
        最近更新 更多