Web基本服務搭建和存取控制

來源:互聯網
上載者:User

標籤:web基本服務搭建和存取控制

              Web服務的基本搭建和存取控制

 環境:

web:

     

[[email protected] ~]# ifconfig | head -2  eth0      Link encap:Ethernet  HWaddr 52:54:01:AC:DE:C4           inet addr:192.168.122.10  Bcast:192.168.122.255  Mask:255.255.255.0   [[email protected]_1 ~]# yum -y install httpd


  NDS:

       

Link encap:Ethernet  HWaddr 52:54:02:AC:DE:C4          inet addr:192.168.122.20  Bcast:192.168.122.255  Mask:255.255.255.0          [[email protected] ~]# rpm -qa  install bind bind-chroot caching-nameserver        bind-9.3.6-20.P1.el5_8.5         bind-chroot-9.3.6-20.P1.el5_8.5        caching-nameserver-9.3.6-20.P1.el5_8.5


一、搭建基本Web服務

1 配置http主設定檔

 

[[email protected]_1 ~]# vim /etc/httpd/conf/httpd.conf74 KeepAlive On265 ServerName www.360.com:80             //本網站的FQDN名稱281 DocumentRoot "/var/www/html"          //網頁文檔的跟目錄391 DirectoryIndex index.html index.php   //預設索引頁/首頁檔案


 2、在局部中設定授權訪問

[[email protected]_1 ~]# cat /etc/httpd/conf/httpd.conf | tail -8 <Directory "/var/www/html">  //針對該目錄下的網頁生效,如果在全域裡設定、則對所有hhtp生效。 Order allow,deny            //拒絕所有 Allow from all              //允許所有 AuthName "Plese"            //認證領域,使用者彈出提示 AuthType basic              //認證類型為Basic AuthUSERFile /etc/httpd/.user  //使用者資料檔案資料路徑 Require valid-user             //有效使用者都可以訪問 #Allow from 192.168.12.50      //只允許192.168.12.50訪問。 </Directory>

 3、建立使用者密碼檔案,建立使用者“abc”,密碼“123”。

[[email protected]_1 ~]# touch /etc/httpd/.user[[email protected]_1 ~]# htpasswd -c /etc/httpd/.user abcNew password:Re-type new password:Adding password for user abc

 4、重啟服務。

 

[[email protected]_1 ~]# service httpd restart[[email protected]_1 ~]# chkconfig httpd on


 5 在/var/www/html下存放一個網頁文檔。

 

[[email protected]_1 ~]# touch  /var/www/html/index.html[[email protected]_1 ~]# vim /var/www/html/index.html[[email protected]_1 ~]# cat /var/www/html/index.htmlwww.360.com


二、 配置DNS用來解析HTTP

 1、編輯DNS主設定檔

   

[[email protected] ~]# cd /var/named/chroot/etc/   [[email protected] etc]# cp -p named.caching-nameserver.conf named.conf[[email protected] etc]# vim named.conf   15         listen-on port 53 { 192.168.122.20; };   26         allow-query     { any; };   27         allow-query-cache { any; };   36         match-clients      { any; };   37         match-destinations { any; };


 2、編輯資料檔案

 

[[email protected] etc]# cat named.rfc1912.zones | tail -4zone "360.com" IN {type master;file "360.zone";};


 3、 編輯地區資料檔案

[[email protected]S etc]# cd /var/named/chroot/var/named/[[email protected] named]# cp -p named.local 360.zone[[email protected] named]# cat  360.zone$TTL86400@       IN      SOA     360.com. root.360.com.  (                                      1997022700 ; Serial                                      28800      ; Refresh                                      14400      ; Retry                                      3600000    ; Expire                                      86400 )    ; Minimum        IN      NS      dns1.360.com.dns1    IN      A       192.168.122.20www     IN      A       192.168.122.10

 4、啟動服務

[[email protected] named]# service named restart[[email protected] named]# chkconfig named on

  檢測:

   在用戶端訪問:要把DNS指向192.168.122.20

650) this.width=650;" src="http://s3.51cto.com/wyfs02/M01/25/8B/wKiom1NjfiejxdY1AAEbGSb7-1w960.jpg" title="e.png" alt="wKiom1NjfiejxdY1AAEbGSb7-1w960.jpg" />


本文出自 “linux網路服務搭建” 部落格,請務必保留此出處http://8824130.blog.51cto.com/8814130/1405567

聯繫我們

該頁面正文內容均來源於網絡整理,並不代表阿里雲官方的觀點,該頁面所提到的產品和服務也與阿里云無關,如果該頁面內容對您造成了困擾,歡迎寫郵件給我們,收到郵件我們將在5個工作日內處理。

如果您發現本社區中有涉嫌抄襲的內容,歡迎發送郵件至: info-contact@alibabacloud.com 進行舉報並提供相關證據,工作人員會在 5 個工作天內聯絡您,一經查實,本站將立刻刪除涉嫌侵權內容。

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.