0

0

Apache HTTP 服务器 2.2 文档

php中文网

php中文网

发布时间:2016-06-07 15:24:38

|

1374人浏览过

|

来源于php中文网

原创

MappingURLstoFilesystemLocations 从 URL 映射到文件系统 DocumentRoot 文档根目录 Indecidingwhatfiletoserveforagivenrequest,Apache'sdefaultbehavioristotake theURL-Pathfortherequest(thepartoftheURLfollowingthehostnameandport)andaddittotheendof

mapping urls to filesystem locations

从 URL 映射到文件系统

DocumentRoot

文档根目录

In deciding what file to serve for a given request, Apache's default behavior is to take 

the URL-Path for the request (the part of the URL following the hostname and port) and add it to the end of the DocumentRoot specified in your configuration files. 

在决定用什么文件响应一个已经到达的请求时,Apache的默认行为是用url路径来响应请求(这一部分的url地址是跟随在主机名和端口号之后的),并且将它添加到在你的配置文件中确定的文档根目录的结尾。

Therefore, the files and directories underneath the DocumentRoot make up the basic document tree which will be visible from the web.

因此,在根目录下的文件和目录将会使服务器的目录结构对于互联网变得可见。

For example, if DocumentRoot were set to /var/www/html then a request for http://www.example.com/fish/guppies.html would result in the file /var/www/html/fish/guppies.html being served to the requesting client.

例如,如果根目录被设置为/var/www/html,之后一个http://www.example.com/fish/guppies.html的网页请求将使文件/var/www/html/fish/guppies.html被送达给请求客户端。

Apache is also capable of Virtual Hosting, where the server receives requests for more than one host. 

Apache也可能是虚拟的主机,此时服务器为超过一个主机接收服务请求。

In this case, a different DocumentRoot can be specified for each virtual host, or alternatively, the directives provided by the module mod_vhost_alias can be used to dynamically determine the appropriate place from which to serve content based on the requested IP address or hostname.

在这种情况,可以为每一个不同的虚拟主机设置不同的根目录,或者采用另一种方法,由模块mod_vhost_alias提供的命令可以用于动态确定服务内容(基于ip地址或者主机名请求)所在的位置。

The DocumentRoot directive is set in your main server configuration file (httpd.conf) and, possibly, once per additional Virtual Host you create.

每当你新建一个额外的虚拟主机的时候,文档根目录指令将会在你的主服务器配置文件(httpd.conf) 里被设置。

Files Outside the DocumentRoot

在文档根目录之外的文件

There are frequently circumstances where it is necessary to allow web access to parts of the filesystem that are not strictly underneath the DocumentRoot. 

经常有一些情况,有必要允许网页连接到一些不严格位于根目录之下的文件系统。

Apache offers several different ways to accomplish this. 

Apache 提供了几种完成这种工作的方法。

On Unix systems, symbolic links can bring other parts of the filesystem under the DocumentRoot. 

在unix系统中,符号链接可以使其他部分的文件系统位于文档根目录之下。

For security reasons, Apache will follow symbolic links only if the Options setting for the relevant directory includes FollowSymLinks or SymLinksIfOwnerMatch.

佳弗O2O系统
佳弗O2O系统

佳弗O2O网站系统——乐活版 环境需求 1. 可用的 www 服务器,如 Apache、Zeus、IIS 等 2. php 4.3.0 及以上 3. Zend Optimizer 2.5.7 及以上 4. MySQL 3.23 及以上,仅针对 MySQL 版 安装 1.安装按照提示流程一步一步安装 2.安装过后如果出现错误,请删除 ./Runtime文件夹 3.如果打开首页 点击导航 出现4

下载

出于安全的原因,Apache只有在相关目录FollowSymLinks或者SymLinksIfOwnerMatch被设置的情况下,才会使符号链接有效。

Alternatively, the Alias directive will map any part of the filesystem into the web space. For example, with 

Alias /docs /var/web

the URL http://www.example.com/docs/dir/file.html will be served from /var/web/dir/file.html.

另一种方法,把Alias目录被映射到其他部分的文件系统。例如,

Alias   /docs /var/web

url地址为http://www.example.com/docs/dir/file.html 的页面请求将用/var/web/dir/file.html页面来响应请求。

 The ScriptAlias directive works the same way, with the additional effect that all content located at the target path is treated as CGI scripts.

Alias脚本命令以同样的方式运行。使用附加的效果:所有位于目标路径的内容被当作CGI脚本

For situations where you require additional flexibility, you can use the AliasMatch and ScriptAliasMatch directives to do powerful regular expression based matching and substitution. For example,

在你需要更灵活的情况下,AliasMatch 和 ScriptAliasMatch命令可以让你使用基于匹配和替换的正则表达式。例如,

ScriptAliasMatch ^/~([a-zA-Z0-9]+)/cgi-bin/(.+) /home/$1/cgi-bin/$2

will map a request to http://example.com/~user/cgi-bin/script.cgi to the path /home/user/cgi-bin/script.cgi and will treat the resulting file as a CGI script.

将会映射http://example.com/~user/cgi-bin/script.cgi的页面请求为/home/user/cgi-bin/script.cgi,并且将最后的文件视为一个CGI 脚本。

User Directories

用户目录

Traditionally on Unix systems, the home directory of a particular user can be referred to as ~user/. The module mod_userdir extends this idea to the web by allowing files under each user's home directory to be accessed using URLs such as the following.

一般来说,在unix系统上,一个用户的主目录可以以~user/来引用。模块mod_userdir 拓展这个思想到了网络,它允许通过url地址来访问位于用户主目录下的文件。如下:

http://www.example.com/~user/file.html

For security reasons, it is inappropriate to give direct access to a user's home directory from the web. Therefore, the UserDir directive specifies a directory underneath the user's home directory where web files are located. Using the default setting of Userdir public_html, the above URL maps to a file at a directory like

/home/user/public_html/file.html where /home/user/ is the user's home directory as specified in /etc/passwd.

出于安全方面的考虑,从网络上直接可以访问用户主目录是不合适的。因此,UserDir命令指定一个位于用户主目录之下的目录用于存放网页文件。使用默认的Userdir public_html设置,上述的url将被映射到某个文件夹下某个的文件,例如:

/home/user/public_html/file.html 。/home/user/是用户的主目录,在/etc/passwd.中被指定。

相关专题

更多
php与html混编教程大全
php与html混编教程大全

本专题整合了php和html混编相关教程,阅读专题下面的文章了解更多详细内容。

1

2026.01.13

PHP 高性能
PHP 高性能

本专题整合了PHP高性能相关教程大全,阅读专题下面的文章了解更多详细内容。

6

2026.01.13

MySQL数据库报错常见问题及解决方法大全
MySQL数据库报错常见问题及解决方法大全

本专题整合了MySQL数据库报错常见问题及解决方法,阅读专题下面的文章了解更多详细内容。

6

2026.01.13

PHP 文件上传
PHP 文件上传

本专题整合了PHP实现文件上传相关教程,阅读专题下面的文章了解更多详细内容。

5

2026.01.13

PHP缓存策略教程大全
PHP缓存策略教程大全

本专题整合了PHP缓存相关教程,阅读专题下面的文章了解更多详细内容。

3

2026.01.13

jQuery 正则表达式相关教程
jQuery 正则表达式相关教程

本专题整合了jQuery正则表达式相关教程大全,阅读专题下面的文章了解更多详细内容。

1

2026.01.13

交互式图表和动态图表教程汇总
交互式图表和动态图表教程汇总

本专题整合了交互式图表和动态图表的相关内容,阅读专题下面的文章了解更多详细内容。

6

2026.01.13

nginx配置文件详细教程
nginx配置文件详细教程

本专题整合了nginx配置文件相关教程详细汇总,阅读专题下面的文章了解更多详细内容。

3

2026.01.13

nginx部署php项目教程汇总
nginx部署php项目教程汇总

本专题整合了nginx部署php项目教程汇总,阅读专题下面的文章了解更多详细内容。

5

2026.01.13

热门下载

更多
网站特效
/
网站源码
/
网站素材
/
前端模板

精品课程

更多
相关推荐
/
热门推荐
/
最新课程
RunnerGo从入门到精通
RunnerGo从入门到精通

共22课时 | 1.7万人学习

尚学堂Mahout视频教程
尚学堂Mahout视频教程

共18课时 | 3.2万人学习

Linux优化视频教程
Linux优化视频教程

共14课时 | 3.1万人学习

关于我们 免责申明 举报中心 意见反馈 讲师合作 广告合作 最新更新
php中文网:公益在线php培训,帮助PHP学习者快速成长!
关注服务号 技术交流群
PHP中文网订阅号
每天精选资源文章推送

Copyright 2014-2026 https://www.php.cn/ All Rights Reserved | php.cn | 湘ICP备2023035733号