httpd的基本應用

來源:互聯網
上載者:User

標籤:httpd基本應用

    建立httpd服務,通過httpd-2.2和httpd2.4實現:

    1、提供基於名稱的虛擬機器主機www1、www2,有單獨的錯誤記錄檔和訪問日誌

    2、通過www1的/server-status的狀態資訊,且允許tom使用者訪問

    3、www2不允許192.168.0.0/24網路中的任意主機訪問

    4、為第二個虛擬機器主機提供https服務


    一、在CentOS上通過httpd-2.2實現以上要求

        1、安裝httpd-2.2的rpm包,

           [[email protected] wordpress]# yum -y install httpd

           [[email protected] wordpress]# rpm -qa |grep httpd

            httpd-tools-2.2.15-45.el6.centos.x86_64

            httpd-2.2.15-45.el6.centos.x86_64

        2、修改httpd的設定檔,建立兩個虛擬機器主機

           [[email protected] ~]# vim /etc/httpd/conf/httpd.conf

           ServerName www1.qq.com:80  找到此行,把前面的#號取消

           NameVirtualHost 172.16.18.5:80 把這前面的#號取消,開啟虛擬機器主機

           建立第一個虛擬機器主機設定檔

           [[email protected] conf.d]# vim vhost1.conf 

           650) this.width=650;" src="http://s2.51cto.com/wyfs02/M02/84/2E/wKiom1eHpTmxd08FAABWJPGN4ag935.png-wh_500x0-wm_3-wmp_4-s_556639903.png" title="02.png" alt="wKiom1eHpTmxd08FAABWJPGN4ag935.png-wh_50" />

              建立第二個虛擬機器主機設定檔

           [[email protected] conf.d]# vim vhost2.conf 

           650) this.width=650;" src="http://s3.51cto.com/wyfs02/M00/84/2E/wKioL1eHpcKRNNywAABHMDu5_u4107.png-wh_500x0-wm_3-wmp_4-s_1562512012.png" title="03.png" alt="wKioL1eHpcKRNNywAABHMDu5_u4107.png-wh_50" />  

           檢查設定檔,並啟動httpd服務

           [[email protected] conf.d]# httpd -t

            Syntax OK

           [[email protected] conf.d]# service httpd restart

            停止 httpd:                                           [確定]

            正在啟動 httpd:                                                 [確定]

            3、建立html資源檔

            650) this.width=650;" src="http://s2.51cto.com/wyfs02/M01/84/2E/wKioL1eHp_rAmIViAAAyukZwBoQ624.png-wh_500x0-wm_3-wmp_4-s_500642419.png" title="01.png" alt="wKioL1eHp_rAmIViAAAyukZwBoQ624.png-wh_50" />

            [[email protected] www1]# vim index.html 

            <h1>www1.site</h1>

            [[email protected] www2]# vim index.html

            <h1>www2.site</h1>

            建立訪問server-status的賬戶 tom

            [[email protected] logs]# htpasswd -c -m                                 /etc/httpd/conf/.htpasswd tom

        4、修改hosts檔案並進行測試

           訪問www1虛擬機器主機,能夠訪問頁面

            

            650) this.width=650;" src="http://s5.51cto.com/wyfs02/M01/84/2E/wKiom1eHqjHB6nbCAAAeUVdN_8E264.png-wh_500x0-wm_3-wmp_4-s_3203852233.png" style="float:none;" title="04.png" alt="wKiom1eHqjHB6nbCAAAeUVdN_8E264.png-wh_50" />

            訪問www2虛擬機器主機,能夠訪問頁面

           650) this.width=650;" src="http://s5.51cto.com/wyfs02/M02/84/2E/wKioL1eHqjGDDZYvAAAbNaHD-MI521.png-wh_500x0-wm_3-wmp_4-s_2637641909.png" style="float:none;" title="05.png" alt="wKioL1eHqjGDDZYvAAAbNaHD-MI521.png-wh_50" />

            通過www1訪問/server-status,需要身分識別驗證

             650) this.width=650;" src="http://s5.51cto.com/wyfs02/M02/84/2E/wKiom1eHqjGD0_b0AAAs9l_vTIY028.png-wh_500x0-wm_3-wmp_4-s_4281048973.png" style="float:none;" title="06.png" alt="wKiom1eHqjGD0_b0AAAs9l_vTIY028.png-wh_50" />


            輸入使用者名稱tom和密碼,能夠訪問狀態資訊

            

Apache Server Status for www1.qq.com
  • Server Version: Apache/2.2.15 (Unix) DAV/2

  • Server Built: Jul 24 2015 11:52:28

  • Current Time: Monday, 20-Jun-2016 01:23:56 CST

  • Restart Time: Monday, 20-Jun-2016 01:20:59 CST

  • Parent Server Generation: 0

  • Server uptime: 2 minutes 57 seconds

  • 1 requests currently being processed, 7 idle workers

_W______........................................................................................................................................................................................................................................................

Scoreboard Key:
"_" Waiting for Connection, "S" Starting up, "R" Reading Request,
"W" Sending Reply, "K" Keepalive (read), "D" DNS Lookup,
"C" Closing connection, "L" Logging, "G" Gracefully finishing,
"I" Idle cleanup of worker, "." Open slot with no current process


          查看記錄檔,也已經自動產生

          [[email protected] logs]# ls

access_log  error_log  www1_access  www1_error  www2_access  www2_error


        通過以上配置和測試,已經滿足前三個要求


            



       

   

                    

        

        


       






                 



       


           




           

本文出自 “linux” 部落格,請務必保留此出處http://wei2008.blog.51cto.com/11351016/1826543

httpd的基本應用

聯繫我們

該頁面正文內容均來源於網絡整理,並不代表阿里雲官方的觀點,該頁面所提到的產品和服務也與阿里云無關,如果該頁面內容對您造成了困擾,歡迎寫郵件給我們,收到郵件我們將在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.