如何在Apache2中允许放置方法

时间:2019-03-01 10:36:56

标签: apache

在以下环境下,正在apache2中测试put方法。


  • 操作系统:Ubuntu 16.04
  • 服务器版本:Apache / 2.4.18(Ubuntu)
  • 服务器内置:2018-06-07T19:43:03
  • WAS:Python CGI

/etc/apache2/apache2.conf
...
<Directory "/var/www/html">
#       Dav On
        Options Indexes FollowSymLinks
        AllowOverride None
        Require all granted
        AddHandler cgi-script .py
        Options ExecCGI
        <LimitExcept GET POST PUT OPTIONS>
                Order Allow,Deny
                Deny from all
        </LimitExcept>
</Directory>
...

和apache2.conf一样,允许使用

PUT方法,但是如果您在根页面上尝试使用OPTIONS方法,则不允许使用PUT方法。 发送PUT请求会导致“方法不允许”错误405。

可以设置所有其他方法,但不能进行PUT和DELETE。 Apache2是默认的安全设置吗?

1 个答案:

答案 0 :(得分:0)

是的,似乎Apache 2.4限制了这些请求,我通过将其添加到webdir文件夹的.htaccess文件中来使其工作:

<Limit GET HEAD POST PUT DELETE OPTIONS>
# Deprecated apache 2.2 syntax:
# Order Allow,Deny
# Allow from all
# Apache > 2.4 requires:
Require all granted
</Limit>