Apache Server 的個案討論

来源:百度文库 编辑:神马文学网 时间:2024/07/05 16:27:20
個案1: 在同一台機器上 提供兩個 http 服務 (by domain name)
說明: 甲公司希望在一台機器上提供 http://www.aco.com.tw 供外界上網查公司的公開資訊,又提供 http://intranet.aco.com.tw 供員工使用內部的一些系統。
做法:
1. 首先在1個IP 上對應2個 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.
#
#
# ServerAdmin webmaster@dummy-host.example.com
# 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
#


DocumentRoot /var/www/html
ServerName www.aco.com.tw
ErrorLog logs/error_www_log
CustomLog logs/access_www_log common


DocumentRoot /var/www/html2
ServerName intranet.aco.com.tw
ErrorLog logs/error_intranet_log
CustomLog logs/access_intranet_log common

個案2: 在同一台機器上 提供兩個 http 服務 (by port number)
說明: 甲公司希望在一台機器上提供 http://www.aco.com.tw 供外界上網查公司的公開資訊,又提供 http://www.aco.com.tw:8080 供員工使用內部的一些系統。
做法:
1. 首先在1個IP 上對應2個 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.
#
#
# ServerAdmin webmaster@dummy-host.example.com
# 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
#


DocumentRoot /var/www/html
ServerName www.aco.com.tw
ErrorLog logs/error_www_log
CustomLog logs/access_www_log common


DocumentRoot /var/www/html2
ServerName intranet.aco.com.tw
ErrorLog logs/error_intranet_log
CustomLog logs/access_intranet_log common

個案3: 以密碼保護網頁
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.mit.edu.tw/linux/apache.htm