Apache Server 的個(gè)案討論
個(gè)案1: 在同一臺(tái)機(jī)器上 提供兩個(gè) http 服務(wù) (by domain name)
說明: 甲公司希望在一臺(tái)機(jī)器上提供 http://www. 供外界上網(wǎng)查公司的公開資訊,,又提供 http://intranet. 供員工使用內(nèi)部的一些系統(tǒng),。
做法:
1. 首先在1個(gè)IP 上對(duì)應(yīng)2個(gè) domain name ( 需由 DNS 加入)
2. 更改 /etc/httpd/conf/httpd.conf 的最後面
#NameVirtualHost * NameVirtualHost 210.240.252.2
# # VirtualHost example: # Almost any Apache directive may go into a VirtualHost container. # The first VirtualHost section is used for requests without a known # server name. # #<VirtualHost *> # ServerAdmin [email protected] # DocumentRoot /www/docs/dummy-host.example.com # ServerName dummy-host.example.com # ErrorLog logs/dummy-host.example.com-error_log # CustomLog logs/dummy-host.example.com-access_log common #</VirtualHost> <VirtualHost 210.240.252.2> DocumentRoot /var/www/html ServerName www. ErrorLog logs/error_www_log CustomLog logs/access_www_log common </VirtualHost> <VirtualHost 210.240.252.2> DocumentRoot /var/www/html2 ServerName intranet. ErrorLog logs/error_intranet_log CustomLog logs/access_intranet_log common </VirtualHost>
個(gè)案2: 在同一臺(tái)機(jī)器上 提供兩個(gè) http 服務(wù) (by port number)
說明: 甲公司希望在一臺(tái)機(jī)器上提供 http://www. 供外界上網(wǎng)查公司的公開資訊,又提供 http://www.:8080 供員工使用內(nèi)部的一些系統(tǒng)。
做法:
1. 首先在1個(gè)IP 上對(duì)應(yīng)2個(gè) domain name ( 需由 DNS 加入)
2. 更改 /etc/httpd/conf/httpd.conf 的 listen 多加一行 Listen 8080
Listen 80 Listen 8080
3. 更改 /etc/httpd/conf/httpd.conf 的最後面
#NameVirtualHost * NameVirtualHost 210.240.232.2
# # VirtualHost example: # Almost any Apache directive may go into a VirtualHost container. # The first VirtualHost section is used for requests without a known # server name. # #<VirtualHost *> # ServerAdmin [email protected] # DocumentRoot /www/docs/dummy-host.example.com # ServerName dummy-host.example.com # ErrorLog logs/dummy-host.example.com-error_log # CustomLog logs/dummy-host.example.com-access_log common #</VirtualHost> <VirtualHost *:80> DocumentRoot /var/www/html ServerName www. ErrorLog logs/error_www_log CustomLog logs/access_www_log common </VirtualHost> <VirtualHost *:8080> DocumentRoot /var/www/html2 ServerName intranet. ErrorLog logs/error_intranet_log CustomLog logs/access_intranet_log common </VirtualHost>
個(gè)案3: 以密碼保護(hù)網(wǎng)頁
1. nano /etc/httpd/conf/httpd.conf
# AllowOverride controls what directives may be placed in .htaccess files. # It can be "All", "None", or any combination of the keywords: # Options FileInfo AuthConfig Limit # # AllowOverride None - by poter AllowOverride All
2. [root@proxyd opt]# htpasswd -c /opt/.htpasswd tom New password: Re-type new password: Adding password for user tom
3. cat /opt/.htpasswd tom:fkzneVy61GKXw
4. nano /var/www/html/.htaccess
AuthUserFile /opt/.htpasswd AuthName "Private directory" AuthType Basic require valid-user
from: http://poterp.iem./linux/apache.htm
|