Apache

//////////2017-1-10 ~ 2017-1-15///////////

int study_data(){

Apache(開源軟件基金會)

Apache:

? ? 1.web服務器
? ? 2.跨平臺,針對不同平臺有不同的編譯版本
? ? 3.快速,可靠
? ? 4.分模塊,可擴充

apache目錄:
? ? 1.bin - 一些可運行的binary程序
? ? 2.conf - 一些配置文件
? ? 3.htdocs - 一些默認的網站文件
? ? 4.logs - 存儲日志
? ? 5.modules - 其他的一些模塊

Apache配置:

? ? ServerRoot:apache軟件的安裝位置。其它指定的目錄如果沒有指定絕對路徑,則目錄是相對于該目錄。
? ? PidFile:第一個httpd進程(所有其他進程的父進程)的進程號文件位置。
? ? Listen:服務器監聽的端口號。
? ? ServerName:主站點名稱(網站的主機名)。
? ? ServerAdmin:管理員的郵件地址。
? ? DocumentRoot:主站點的網頁存儲位置。

對主站點的目錄進行訪問控制:

? ? <Directory "/mnt/web/clusting">
? ? ? ? Options FollowSymLinks
? ? ? ? AllowOverride None
? ? ? ? Order allow,deny
? ? ? ? Allow from all
? ? </Directory>

主要配置

Options:

? ? 配置在特定目錄使用哪些特性,常用的值和基本含義如下:
? ? ExecCGI: 在該目錄下允許執行CGI腳本。
? ? FollowSymLinks: 在該目錄下允許文件系統使用符號連接。
? ? Indexes: 當用戶訪問該目錄時,如果用戶找不到DirectoryIndex指定的主頁文件(例如index.html), 則返回該目錄下的文件列表給用戶。
? ? SymLinksIfOwnerMatch: 當使用符號連接時,只有當符號連接的文件擁有者與實際文件的擁有者相同時才可以訪問。

AllowOverride:

? ? 允許存在于.htaccess文件中的指令類型(.htaccess文件名是可以改變的,其文件名由 ? ?AccessFileName指令決定):
? ? None: 當AllowOverride被設置為None時。不搜索該目錄下的.htaccess文件(可以減小服務器開銷)。
? ? All: 在.htaccess文件中可以使用所有的指令。

Order:

? ? 控制在訪問時Allow和Deny兩個訪問規則哪個優先:
? ? Allow:允許訪問的主機列表(可用域名或子網,例如:Allow from 192.168.0.0/16)。
? ? Deny:拒絕訪問的主機列表。

虛擬主機的配置?

1.基于IP地址的虛擬主機配置?

? ? Listen 80

? ? <VirtualHost 172.20.30.40>
? ? ? ? DocumentRoot /www/example1
? ? ? ? ServerName www.example1.com
? ? </VirtualHost>

? ? <VirtualHost 172.20.30.50>
? ? ? ? DocumentRoot /www/example2
? ? ? ? ServerName www.example2.org
? ? </VirtualHost>

2.基于IP和多端口的虛擬主機配置?

? ? Listen 172.20.30.40:80
? ? Listen 172.20.30.40:8080
? ? Listen 172.20.30.50:80
? ? Listen 172.20.30.50:8080

? ? <VirtualHost 172.20.30.40:80>
? ? ? ? DocumentRoot /www/example1-80
? ? ? ? ServerName www.example1.com
? ? </VirtualHost>

? ? <VirtualHost 172.20.30.40:8080>
? ? ? ? DocumentRoot /www/example1-8080
? ? ? ? ServerName www.example1.com
? ? </VirtualHost>

? ? <VirtualHost 172.20.30.50:80>
? ? ? ? DocumentRoot /www/example2-80
? ? ? ? ServerName www.example1.org
? ? </VirtualHost>

? ? <VirtualHost 172.20.30.50:8080>
? ? ? ? DocumentRoot /www/example2-8080
? ? ? ? ServerName www.example2.org
? ? </VirtualHost>

3.單個IP地址的服務器上基于域名的虛擬主機配置:

? ? ?# Ensure that Apache listens on port 80
? ? Listen 80?

? ? # Listen for virtual host requests on all IP addresses
? ? NameVirtualHost *:80

? ? <VirtualHost *:80>
? ? ? ? DocumentRoot /www/example1
? ? ? ? ServerName www.example1.com
? ? ? ? ServerAlias example1.com. *.example1.com
? ? ? ? # Other directives here
? ? </VirtualHost>

? ? <VirtualHost *:80>
? ? ? ? DocumentRoot /www/example2
? ? ? ? ServerName www.example2.org
? ? ? ? # Other directives here
? ? </VirtualHost>

4.在多個IP地址的服務器上配置基于域名的虛擬主機:?

? ? Listen 80?

? ? # This is the "main" server running on 172.20.30.40
? ? ServerName server.domain.com
? ? DocumentRoot /www/mainserver?

? ? # This is the other address
? ? NameVirtualHost 172.20.30.50

? ? <VirtualHost 172.20.30.50>
? ? ? ? DocumentRoot /www/example1
? ? ? ? ServerName www.example1.com
? ? ? ? # Other directives here ...
? ? </VirtualHost>

? ? <VirtualHost 172.20.30.50>
? ? ? ? DocumentRoot /www/example2
? ? ? ? ServerName www.example2.org
? ? ? ? # Other directives here ...
? ? </VirtualHost>

5.在不同的端口上運行不同的站點(基于多端口的服務器上配置基于域名的虛擬主機):?

? ? Listen 80
? ? Listen 8080?

? ? NameVirtualHost 172.20.30.40:80
? ? NameVirtualHost 172.20.30.40:8080

? ? <VirtualHost 172.20.30.40:80>
? ? ? ? ServerName www.example1.com
? ? ? ? DocumentRoot /www/domain-80
? ? </VirtualHost>

? ? <VirtualHost 172.20.30.40:8080>
? ? ? ? ServerName www.example1.com
? ? ? ? DocumentRoot /www/domain-8080
? ? </VirtualHost>

? ? <VirtualHost 172.20.30.40:80>
? ? ? ? ServerName www.example2.org
? ? ? ? DocumentRoot /www/otherdomain-80
? ? </VirtualHost>

? ? <VirtualHost 172.20.30.40:8080>
? ? ? ? ServerName www.example2.org
? ? ? ? DocumentRoot /www/otherdomain-8080
? ? </VirtualHost>

6.基于域名和基于IP的混合虛擬主機的配置:?

? ? Listen 80?

? ? NameVirtualHost 172.20.30.40

? ? <VirtualHost 172.20.30.40>
? ? ? ? DocumentRoot /www/example1
? ? ? ? ServerName www.example1.com
? ? </VirtualHost>

? ? <VirtualHost 172.20.30.40>
? ? ? ? DocumentRoot /www/example2
? ? ? ? ServerName www.example2.org
? ? </VirtualHost>

? ? <VirtualHost 172.20.30.40>
? ? ? ? DocumentRoot /www/example3
? ? ? ? ServerName www.example3.net
? ? </VirtualHost>

最后編輯于
?著作權歸作者所有,轉載或內容合作請聯系作者
平臺聲明:文章內容(如有圖片或視頻亦包括在內)由作者上傳并發布,文章內容僅代表作者本人觀點,簡書系信息發布平臺,僅提供信息存儲服務。

推薦閱讀更多精彩內容