搜索
您的当前位置:首页正文

httpd

来源:好走旅游网

官方reference:


httpd主要是一个静态文件服务器。当然不限于此,通过各种mod,httpd也可以作为一个前端服务器,把请求转发到servlet container、cgi等。不过主要还是静态文件服务器,所以官方的reference也是从处理静态文件说起 

1. DocumentRoot 

首先要把浏览器里的url,映射到server的文件系统上 

这是通过DocumentRoot directive配置的(httpd的各种配置,都是用directive完成的,各种mod提供了不同的directive) 

DocumentRoot "/usr/local/httpd/htdocs"

这里把url的"/",映射到了/usr/local/httpd/htdocs目录下,比如: 

http://localhost/helloword,会映射到/usr/local/httpd/htdocs/helloword这个文件 

http://localhost/web/,会映射到/usr/local/httpd/htdocs/web/这个文件夹下(区别在于结尾的"/") 

2. DirectoryIndex 

另外有一个directive叫做DirectoryIndex,是用来自动处理文件夹的 
<IfModule dir_module>
    DirectoryIndex index.html
</IfModule>

这样配置之后,如果url请求访问一个目录,则httpd会先到这个目录下寻找index.html,找到则返回;如果没有找到,则显示目录列表 

这也是为什么,访问http://localhost,会显示success page 


因篇幅问题不能全部显示,请点此查看更多更全内容

Top