最新文章專題視頻專題問答1問答10問答100問答1000問答2000關鍵字專題1關鍵字專題50關鍵字專題500關鍵字專題1500TAG最新視頻文章推薦1 推薦3 推薦5 推薦7 推薦9 推薦11 推薦13 推薦15 推薦17 推薦19 推薦21 推薦23 推薦25 推薦27 推薦29 推薦31 推薦33 推薦35 推薦37視頻文章20視頻文章30視頻文章40視頻文章50視頻文章60 視頻文章70視頻文章80視頻文章90視頻文章100視頻文章120視頻文章140 視頻2關鍵字專題關鍵字專題tag2tag3文章專題文章專題2文章索引1文章索引2文章索引3文章索引4文章索引5123456789101112131415文章專題3
問答文章1 問答文章501 問答文章1001 問答文章1501 問答文章2001 問答文章2501 問答文章3001 問答文章3501 問答文章4001 問答文章4501 問答文章5001 問答文章5501 問答文章6001 問答文章6501 問答文章7001 問答文章7501 問答文章8001 問答文章8501 問答文章9001 問答文章9501
當前位置: 首頁 - 科技 - 知識百科 - 正文

ApacheHTTP服務器2.2文檔

來源:懂視網(wǎng) 責編:小采 時間:2020-11-09 15:42:09
文檔

ApacheHTTP服務器2.2文檔

ApacheHTTP服務器2.2文檔:MappingURLstoFilesystemLocations 從 URL 映射到文件系統(tǒng) DocumentRoot 文檔根目錄 Indecidingwhatfiletoserveforagivenrequest,Apache'sdefaultbehavioristotake theURL-Pathfortherequest(theparto
推薦度:
導讀ApacheHTTP服務器2.2文檔:MappingURLstoFilesystemLocations 從 URL 映射到文件系統(tǒng) DocumentRoot 文檔根目錄 Indecidingwhatfiletoserveforagivenrequest,Apache'sdefaultbehavioristotake theURL-Pathfortherequest(theparto

MappingURLstoFilesystemLocations 從 URL 映射到文件系統(tǒng) DocumentRoot 文檔根目錄 Indecidingwhatfiletoserveforagivenrequest,Apache'sdefaultbehavioristotake theURL-Pathfortherequest(thepartoftheURLfollowingthehostnameandport)andaddittotheendof

Mapping URLs to Filesystem Locations

從 URL 映射到文件系統(tǒng)

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.

在決定用什么文件響應一個已經(jīng)到達的請求時,Apache的默認行為是用url路徑來響應請求(這一部分的url地址是跟隨在主機名和端口號之后的),并且將它添加到在你的配置文件中確定的文檔根目錄的結尾。

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

因此,在根目錄下的文件和目錄將會使服務器的目錄結構對于互聯(lián)網(wǎng)變得可見。

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的網(wǎng)頁請求將使文件/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提供的命令可以用于動態(tài)確定服務內容(基于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.

經(jīng)常有一些情況,有必要允許網(wǎng)頁連接到一些不嚴格位于根目錄之下的文件系統(tǒng)。

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系統(tǒng)中,符號鏈接可以使其他部分的文件系統(tǒng)位于文檔根目錄之下。

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

出于安全的原因,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目錄被映射到其他部分的文件系統(tǒng)。例如,

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系統(tǒng)上,一個用戶的主目錄可以以~user/來引用。模塊mod_userdir 拓展這個思想到了網(wǎng)絡,它允許通過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.

出于安全方面的考慮,從網(wǎng)絡上直接可以訪問用戶主目錄是不合適的。因此,UserDir命令指定一個位于用戶主目錄之下的目錄用于存放網(wǎng)頁文件。使用默認的Userdir public_html設置,上述的url將被映射到某個文件夾下某個的文件,例如:

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

聲明:本網(wǎng)頁內容旨在傳播知識,若有侵權等問題請及時與本網(wǎng)聯(lián)系,我們將在第一時間刪除處理。TEL:177 7030 7066 E-MAIL:11247931@qq.com

文檔

ApacheHTTP服務器2.2文檔

ApacheHTTP服務器2.2文檔:MappingURLstoFilesystemLocations 從 URL 映射到文件系統(tǒng) DocumentRoot 文檔根目錄 Indecidingwhatfiletoserveforagivenrequest,Apache'sdefaultbehavioristotake theURL-Pathfortherequest(theparto
推薦度:
標簽: 文件 文檔 服務器
  • 熱門焦點

最新推薦

猜你喜歡

熱門推薦

專題
Top