Http的轻微配置
目標:
我們開始吧!我的環境是redhat 5.8,已安裝自帶的bind97,bind97_lib,bind97_utils,httpd2.2.3,
1.建立DNS服務器。建立/etc/named.conf,并為之建立各自區域文件,啟動named服務,測試,并把測試機(我用的是我的xp)的DNS改為剛建立的DNS的地址
1: /etc/named.conf : 2: ? 3: options { 4: directory "/var/named"; 5: }; 6: zone "linux.com" IN { 7: type master; 8: file "linux.php.apache"; 9: }; 10: zone "php.net" IN { 11: type master; 12: file "linux.php.apache"; 13: }; 14: zone "apache.org" IN { 15: type master; 16: file "linux.php.apache"; 17: }; 18: ? 19: /var/named/linux.php.apache 20: ? 21: ? 22: $TTL 86400 23: @ IN SOA ns admin ( 24: 001 25: 2H 26: 5M 27: 7D 28: 2H ) 29: IN NS ns 30: ns IN A 172.16.1.1 31: www IN A 172.16.1.1 ?2.修改/etc/httpd/conf/httpd.conf,注釋主服務器區域的文檔目錄欄,取消基于域名的虛擬主機選項,然后建立虛擬機主機.新建幾個目錄,與日志文件,更改權限
1: #DocumentRoot "/var/www/html" ##282行左右 2: NameVirtualHost *:80 ##973行左右取消注釋 3: ##在最后建立三個虛擬主機 4: <VirtualHost *:80> 5: ServerName "www.linux.com" 6: DocumentRoot /www/linux 7: ErrorLog /www/logs/linux-error_log 8: CustomLog /www/logs/linux-access_log common 9: </VirtualHost> 10: <VirtualHost *:80> 11: ServerName "www.php.net" 12: DocumentRoot /www/php 13: ErrorLog /www/logs/php-error_log 14: CustomLog /www/logs/php-access_log common 15: </VirtualHost> 16: <VirtualHost *:80> 17: ServerName "www.apache.org" 18: DocumentRoot /www/apache 19: ErrorLog /www/logs/apache-error_log 20: CustomLog /www/logs/apache-access_log common 21: </VirtualHost> 22: ? 23: mkdir /www/{linux,php,apache/logs}; ##建立目錄 24: touch /www/logs/{linux-error_log,linux-access_log,php-error_log,php-access_log,apache-access_log,apache-error_log}; 25: echo "I am linux " >/www/linux/index.html; 26: echo "I am php " >/www/php/index.html; 27: echo "I am linux " >/www/apache/index.html; 28: chown apache:apache -R /www?
3.修改名字為www.linux.com虛擬主機的訪問權限
1: <VirtualHost *:80> 2: ServerName "www.linux.com" 3: DocumentRoot /www/linux 4: ErrorLog /www/logs/linux-error_log 5: CustomLog /www/logs/linux-access_log common 6: <Directory "/www/linux"> 7: Order Allow,Deny 8: Allow From 172.16.0.0/16 9: Deny From 172.16.100.0/24 10: </Directory> 11: </VirtualHost> 4.為www.linux.com建立證書,方法見http://laoguang.blog.51cto.com/6013350/1035608 5.安裝mod_ssl這個模塊,基于ssl訪問的https由它提供,修改它的配置文件/etc/httpd/conf.d/ssl.conf 1: yum -y install mod_ssl ##已配好yum,自動安裝 2: ? 3: /etc/httpd/conf.d/ssl.conf 4: ? 5: DocumentRoot "/www/linux" ##86行加入這兩行 6: ServerName www.linux.com 7: SSLCertificateFile /etc/httpd/conf.d/linux.crt ##113行左右修改為SSL的證書的位置 (這是我建立證書的位置) 8: SSLCertificateKeyFile /etc/httpd/conf.d/linux.key ##120行左右修改為SSL的私鑰的位置 6.為www.php.net 設定訪問權限 1: <VirtualHost *:80> 2: ServerName "www.php.net" 3: DocumentRoot /www/php 4: ErrorLog /www/logs/php-error_log 5: CustomLog /www/logs/php-access_log common 6: <Directory /www/php> 7: AllowOverride Authconfig 8: options none 9: Authtype basic 10: Authname "Hi,I'm secreat" 11: AuthUserFile /etc/httpd/conf.d/htpasswd 12: Require valid-user 13: </Directory> 14: </VirtualHost> ? 1: htpasswd -c -m /etc/httpd/conf.d/htpasswd laoguang 2: New password: 3: Re-type new password: ? 1: <VirtualHost *:80> 2: ServerName "www.apache.org" 3: DocumentRoot /www/apache 4: ErrorLog /www/logs/apache-error_log 5: CustomLog /www/logs/apache-access_log common 6: alias /mail "/web/mail" 7: AddHandler cgi-script .cgi 8: <Directory /web/mail> 9: Options execCGI 10: </Directory> 11: </VirtualHost> ? 1: vim /www/apache/test.cgi 2: ? 3: #!/bin/bash 4: cat <<EOF 5: Content-Type: text/html 6: ? 7: <pre> 8: $(/bin/date) 9: my name is `id -nu` 10: my hostname $HOSTNAME 11: `/bin/date` 12: `echo $PATH` 13: </pre> 14: EOF 15: ? 16: ? 17: ##瀏覽器訪問 www.apache.org/mail/test.cgi看是否能正常執行總結
- 上一篇: 初涉c#设计模式-Iterator Pa
- 下一篇: Java_BigInteger