httpd 2.4 支持 PUT 和 GET 吗?

Posted

技术标签:

【中文标题】httpd 2.4 支持 PUT 和 GET 吗?【英文标题】:Does httpd 2.4 support PUT and GET? 【发布时间】:2019-11-01 04:29:25 【问题描述】:

我在 CentOS 7 机器上安装了 httpd-2.4.6-89.el7.centos.x86_64 并配置了网络服务器,但是我无法让 http 'PUT/POST' 或 'GET' 工作

下面说的是我的配置

[root@centos-007 httpd]# cat /etc/httpd/conf.d/centos-007.conf
<VirtualHost *:80>
    ServerName centos-007.gg.com
    DocumentRoot "/abc/xyz"
        DirectoryIndex index.html
        <Location />
        Require all granted
        Options +Indexes
        </Location>
    Alias /avaya  "/abc/xyz"
    <Directory "/abc/xyz">
    Require all granted
    Dav On
    <LimitExcept GET POST OPTIONS>
    </LimitExcept>
    Options FollowSymLinks Indexes MultiViews
    </Directory>
</VirtualHost>
<VirtualHost *:80>
    ServerName centos-007
    DocumentRoot /var/www/centos-007/pub_html
    <Directory /var/www/centos-007/pub_html>
    Options Indexes FollowSymLinks MultiViews
    Require all granted
    </Directory>
</VirtualHost>

奇怪的是,当我运行 curl 命令上传文件时,我得到以下信息,但是网页没有显示上传的文件

* About to connect() to centos-007.gg.com port 80 (#0)
*   Trying 10.170.110.100...
* Connected to centos-007.gg.com (10.170.110.100) port 80 (#0)
> PUT /avaya HTTP/1.1
> User-Agent: curl/7.29.0
> Host: centos-007.gg.com
> Accept: */*
> Content-Length: 824
> Expect: 100-continue
>
< HTTP/1.1 301 Moved Permanently
< Date: Tue, 18 Jun 2019 13:25:54 GMT
< Server: Apache/2.4.6 (CentOS)
< Location: http://centos-007.wsgc.com/xyx
< Content-Length: 245
< Connection: close
< Content-Type: text/html; charset=iso-8859-1
<
<!DOCTYPE HTML PUBLIC "-//IETF//DTD HTML 2.0//EN">
<html><head>
<title>301 Moved Permanently</title>
</head><body>
<h1>Moved Permanently</h1>
<p>The document has moved <a href="http://centos-007.gg.com/xyx">here</a>.</p>
</body></html>
* Closing connection 0

【问题讨论】:

这是专门针对webdav...? 我所需要的只是放置文件的能力,我对模块并不具体 【参考方案1】:

我可以使用底层来完成这项工作

DavLockDB /var/www/html/DavLock
<VirtualHost *:80>
    ServerName centos-007.gg.com 
    DocumentRoot /abc/xyz
<Location />
    Require all granted
    Options +Indexes
</Location>
    ErrorLog /var/log/httpd/error.log
    CustomLog /var/log/httpd/access.log combined
    Alias /xyz  /abc/xyz
    <Directory  /abc/xyz>
        Require all granted
        DAV On
        AuthType Basic
        Require valid-user
    </Directory>
</VirtualHost>

【讨论】:

以上是关于httpd 2.4 支持 PUT 和 GET 吗?的主要内容,如果未能解决你的问题,请参考以下文章

centos7之httpd-2.4的新特性

Httpd-2.4的新特性

关于2.4版本以后apache/httpd开始不支持下划线header的解决方法

CentOS6 编译安装httpd-2.4

lamp编译安装

Centos 6 apache httpd 2.4 主要配置详解