標籤:web伺服器 include blank target manual
第二章實驗(一):web服務類別目錄的存取權限的控制
1.確認web伺服器已經安裝並啟動
[[email protected] ~]# ls /usr/local/httpd/
bin build cgi-bin conf error htdocs icons include lib logs man manual modules
650) this.width=650;" style="background-image: none; border-bottom: 0px; border-left: 0px; padding-left: 0px; padding-right: 0px; border-top: 0px; border-right: 0px; padding-top: 0px" title="clip_image002" border="0" alt="clip_image002" src="http://s3.51cto.com/wyfs02/M02/87/08/wKiom1fSBp3SZPzZAABicCLuMyY375.jpg" "504" height="137" />
[[email protected] ~]# netstat -utpln |grep 80
tcp 0 0 :::80 :::* LISTEN 73341/httpd
650) this.width=650;" style="background-image: none; border-bottom: 0px; border-left: 0px; padding-left: 0px; padding-right: 0px; border-top: 0px; border-right: 0px; padding-top: 0px" title="clip_image004" border="0" alt="clip_image004" src="http://s3.51cto.com/wyfs02/M01/87/07/wKioL1fSBqOQ3W5eAAA3Lot7zzM223.jpg" "504" height="120" />
2.設定只允許192.168.100.110訪問,其他主機拒絕:
[[email protected] ~]# vim /usr/local/httpd/conf/httpd.conf
421 <Directory "/usr/local/awstats/wwwroot">
422 Options None
423 AllowOverride None
424 Order allow,deny
425 Allow from 192.168.100.110 ##修改該行
426 </Directory>
427
:set nu ##列印行號
:wq
650) this.width=650;" style="background-image: none; border-bottom: 0px; border-left: 0px; padding-left: 0px; padding-right: 0px; border-top: 0px; border-right: 0px; padding-top: 0px" title="clip_image006" border="0" alt="clip_image006" src="http://s3.51cto.com/wyfs02/M00/87/08/wKiom1fSBqTwFjQHAABaFO7Hqro403.jpg" "504" height="175" />
[[email protected] ~]# /etc/init.d/httpd restart ##重啟服務
httpd is restart complete.
650) this.width=650;" style="background-image: none; border-bottom: 0px; border-left: 0px; padding-left: 0px; padding-right: 0px; border-top: 0px; border-right: 0px; padding-top: 0px" title="clip_image008" border="0" alt="clip_image008" src="http://s3.51cto.com/wyfs02/M00/87/07/wKioL1fSBqfiYZeOAAAuzsF5gh8795.jpg" "504" height="101" />
測試:
修改windows主機的VNET1的IP為192.168.100.1,訪問測試:
650) this.width=650;" style="background-image: none; border-bottom: 0px; border-left: 0px; padding-left: 0px; padding-right: 0px; border-top: 0px; border-right: 0px; padding-top: 0px" title="clip_image009" border="0" alt="clip_image009" src="http://s3.51cto.com/wyfs02/M00/87/07/wKioL1fSBquAFuvOAAGqz7MSgbE868.png" "504" height="558" />
http://www.linuxfan.cn/aws.html ##不能訪問
650) this.width=650;" style="background-image: none; border-bottom: 0px; border-left: 0px; padding-left: 0px; padding-right: 0px; border-top: 0px; border-right: 0px; padding-top: 0px" title="clip_image011" border="0" alt="clip_image011" src="http://s3.51cto.com/wyfs02/M01/87/08/wKiom1fSBqyBXQoNAABH4-5rwoM981.jpg" "504" height="158" />
http://www.linuxfan.cn ##能訪問
650) this.width=650;" style="background-image: none; border-bottom: 0px; border-left: 0px; padding-left: 0px; padding-right: 0px; border-top: 0px; border-right: 0px; padding-top: 0px" title="clip_image013" border="0" alt="clip_image013" src="http://s3.51cto.com/wyfs02/M00/87/08/wKiom1fSBqyRC6jFAAA_JeXUGz4100.jpg" "504" height="183" />
修改windows主機的VNET1的IP為192.168.100.110,訪問測試:
650) this.width=650;" style="background-image: none; border-bottom: 0px; border-left: 0px; padding-left: 0px; padding-right: 0px; border-top: 0px; border-right: 0px; padding-top: 0px" title="clip_image014" border="0" alt="clip_image014" src="http://s3.51cto.com/wyfs02/M01/87/08/wKiom1fSBrHz9avlAAHSw6uwRHA752.png" "504" height="527" />
http://www.linuxfan.cn/aws.html ##能訪問
650) this.width=650;" style="background-image: none; border-bottom: 0px; border-left: 0px; padding-left: 0px; padding-right: 0px; border-top: 0px; border-right: 0px; padding-top: 0px" title="clip_image016" border="0" alt="clip_image016" src="http://s3.51cto.com/wyfs02/M02/87/08/wKiom1fSBrLxXP5HAACBQBk6zRM049.jpg" "504" height="260" />
http://www.linuxfan.cn ##能訪問
650) this.width=650;" style="background-image: none; border-bottom: 0px; border-left: 0px; padding-left: 0px; padding-right: 0px; border-top: 0px; border-right: 0px; padding-top: 0px" title="clip_image018" border="0" alt="clip_image018" src="http://s3.51cto.com/wyfs02/M02/87/07/wKioL1fSBsaCAB_1AABAFyh0W-I022.jpg" "504" height="231" />
3.使用者授許可權制:
1)建立認證使用者的密碼檔案(password file):
[[email protected] ~]# /usr/local/httpd/bin/htpasswd -c /usr/local/httpd/conf/htpasswd admin ##添加admin使用者
New password: ##輸入密碼[email protected]
Re-type new password: ##確認密碼
Adding password for user admin
650) this.width=650;" style="background-image: none; border-bottom: 0px; border-left: 0px; padding-left: 0px; padding-right: 0px; border-top: 0px; border-right: 0px; padding-top: 0px" title="clip_image020" border="0" alt="clip_image020" src="http://s3.51cto.com/wyfs02/M00/87/08/wKiom1fSBsqTC1axAAB7H78bRXY531.jpg" "504" height="176" />
[[email protected] ~]# cat /usr/local/httpd/conf/htpasswd
admin:TpPLVJuXl0wsE
650) this.width=650;" style="background-image: none; border-bottom: 0px; border-left: 0px; padding-left: 0px; padding-right: 0px; border-top: 0px; border-right: 0px; padding-top: 0px" title="clip_image022" border="0" alt="clip_image022" src="http://s3.51cto.com/wyfs02/M01/87/09/wKiom1fSCGijAT-uAABFjnAqxX4750.jpg" "504" height="123" />
相同的方法分別添加jhon,fage兩個使用者。
650) this.width=650;" style="background-image: none; border-bottom: 0px; border-left: 0px; padding-left: 0px; padding-right: 0px; border-top: 0px; border-right: 0px; padding-top: 0px" title="clip_image024" border="0" alt="clip_image024" src="http://s3.51cto.com/wyfs02/M00/87/07/wKioL1fSCG3jVeHvAAEkk1Oo-CI130.jpg" "504" height="388" />
[[email protected] ~]# vim /usr/local/httpd/conf/htgroups ##為授權使用者加入組
mygroup: admin fage ##組名: 成員1 成員2
650) this.width=650;" style="background-image: none; border-bottom: 0px; border-left: 0px; padding-left: 0px; padding-right: 0px; border-top: 0px; border-right: 0px; padding-top: 0px" title="clip_image026" border="0" alt="clip_image026" src="http://s3.51cto.com/wyfs02/M02/87/09/wKiom1fSCHHQjS0lAABK_9iP8q0227.jpg" "504" height="199" />
2)添加使用者授權配置
[[email protected] ~]# vim /usr/local/httpd/conf/httpd.conf
421 <Directory "/usr/local/awstats/wwwroot">
422 Options None
423 AllowOverride None
424 Order allow,deny
425 Allow from 192.168.100.110
426 AuthType Basic ##定義認證的類型為Basic
427 AuthName "Log analysis system" ##提示短語
428 AuthBasicProvider file ##提供認證者為file
429 AuthUserFile /usr/local/httpd/conf/htpasswd ##指定認證使用者檔案
430 AuthGroupFile /usr/local/httpd/conf/htgroups ##指定認證組檔案
431 Require group mygroup ##設定允許訪問的使用者或者組,如果設定為使用者改為“Require valid-user”即可
432 </Directory>
433
:set nu
:wq
650) this.width=650;" style="background-image: none; border-bottom: 0px; border-left: 0px; padding-left: 0px; padding-right: 0px; border-top: 0px; border-right: 0px; padding-top: 0px" title="clip_image028" border="0" alt="clip_image028" src="http://s3.51cto.com/wyfs02/M01/87/07/wKioL1fSCHSxp-vjAADLQ1O14Ns274.jpg" "504" height="345" />
[[email protected] ~]# /etc/init.d/httpd restart ##重啟服務
httpd is restart complete.
650) this.width=650;" style="background-image: none; border-bottom: 0px; border-left: 0px; padding-left: 0px; padding-right: 0px; border-top: 0px; border-right: 0px; padding-top: 0px" title="clip_image030" border="0" alt="clip_image030" src="http://s3.51cto.com/wyfs02/M00/87/09/wKiom1fSCHaR0UKTAAAujWRG5v4114.jpg" "504" height="100" />
3)訪問測試:
http://www.linuxfan.cn/aws.html ##輸入使用者測試,admin與fage能登入,jhon不能登入
注意驗證不同使用者時只需關閉重新開啟即可
650) this.width=650;" style="background-image: none; border-bottom: 0px; border-left: 0px; padding-left: 0px; padding-right: 0px; border-top: 0px; border-right: 0px; padding-top: 0px" title="clip_image032" border="0" alt="clip_image032" src="http://s3.51cto.com/wyfs02/M02/87/07/wKioL1fSCHiRTEXtAABR2cOScGA024.jpg" "504" height="271" />
650) this.width=650;" style="background-image: none; border-bottom: 0px; border-left: 0px; padding-left: 0px; padding-right: 0px; border-top: 0px; border-right: 0px; padding-top: 0px" title="clip_image034" border="0" alt="clip_image034" src="http://s3.51cto.com/wyfs02/M00/87/07/wKioL1fSCICTonHYAACE2HKdCBI827.jpg" "504" height="270" />
650) this.width=650;" style="background-image: none; border-bottom: 0px; border-left: 0px; padding-left: 0px; padding-right: 0px; border-top: 0px; border-right: 0px; padding-top: 0px" title="clip_image036" border="0" alt="clip_image036" src="http://s3.51cto.com/wyfs02/M01/87/07/wKioL1fSCIuQ9l9oAABMnTv-Jt8769.jpg" "504" height="263" />
650) this.width=650;" style="background-image: none; border-bottom: 0px; border-left: 0px; padding-left: 0px; padding-right: 0px; border-top: 0px; border-right: 0px; padding-top: 0px" title="clip_image038" border="0" alt="clip_image038" src="http://s3.51cto.com/wyfs02/M02/87/07/wKioL1fSCI7hvDYqAACA7mXHgA0653.jpg" "504" height="263" />
(一):web服務存取權限的控制