實驗1配置HTTPD
實驗環境
在虛擬機Linux 6.5系統下需要2臺Linux系統一臺A作爲服務端一條B作爲測試客戶端win7真實主機開啓2臺Linux系統。
實驗目標
A作爲服務端配置VSFTPD服務器實現FTP服務。
B作爲測試客戶端驗證服務器A的共享是否有效。
配置真實主機確保真實主機能ping通2臺虛擬機。
實驗步驟
1. 首先將A,B真實主機放到同一網段中爲了以後實驗方便配置永久起效的靜態IP地址驗證AB真實主機能否通信安裝HTTPD服務並啓動。
[root@s5 ~]#cd/etc/httpd/conf/
[root@s5 conf]#cphttpd.conf httpd.conf.gz//備份主配置文件
[root@s5conf]#vim httpd.conf
ServerNames5.tarena.com
[root@s5~]#/etc/init.d/httpd restart //重啓服務
2. 部署網頁文檔
[root@s5 ~]#cd/var/www/html/
[root@s5 html]#vim index.html
Hello World !
3. 瀏覽器訪問禁止使用符號鏈接>配置文件並且當主頁不存在時報出錯誤。
在Win7瀏覽器上輸入http://192.168.1.1查看顯示信息
[root@s5conf]#vim httpd.conf
<Directory/>
304 Options –FollowSymLinks //禁止符號鏈接
305 AllowOverride None
306 </Directory>
[root@s5conf]#vim ../conf.d/welcome.conf //子配置文件
Options Indexes //當主頁不存在時報出錯誤
4. 使用目錄別名
[root@s5conf]#vim httpd.conf
Alias /doc/"/var/www/dev/" //爲www下子目錄設置別名在瀏覽器上直接輸入地址+/doc/ 直接訪問。
[root@s5 www]#/etc/init.d/httpd restart
http//192.168.1.1/doc/
5. 爲指定目錄啓用用戶授權
1在網站根目錄下建一個子目錄studir
能訪問 http://服務器地址/studir/
2給studir添加用戶授權只允許用戶stu01訪問密碼123456
[root@s5 桌面]#cd /var/www/html/
[root@s5 html]#mkdir studir //創建目錄
[root@s5 html]#htpasswd -c/etc/httpd/authpwd stu01
//添加訪問用戶當添加第二個用戶時若不想覆蓋原來的用戶不需加-c若覆蓋加上-c
New password:
Re-type new password:
Adding password foruser stu01
[root@s5 conf]#vimhttpd.conf
<Directory"var/www/html/studir">
AuthName"Tarena Library."
AuthType basic
AuthUserFile /etc/httpd/authpwd
Require valid-user
#Require user stu01
</Directory>