HTTP

使用CentOS 7和CentOS 6實現以下任務

  • 配置四個基于名稱的虛擬主機;
    discuzX
    wordpress
    drupal
    1.在conf.d下新建并編輯虛擬主機配置文件
    ]# cd /etc/httpd/conf.d/
    ]# vim vhost.conf
    centos6配置

      [root@ _93_ conf.d]# cat /etc/httpd/conf.d/vhost.conf
      NameVirtualHost *:80
      <VirtualHost *:80>
          ServerName www.discuzx.com
          DocumentRoot "/vhost/discuzx/"
      </VirtualHost>
      <VirtualHost *:80>
          ServerName www.wordpress.com
          DocumentRoot "/vhost/wordpress/"
      </VirtualHost>
      <VirtualHost *:80>
          ServerName www.drupal.com
          DocumentRoot "/vhost/drupal/"
      </VirtualHost>

    centos7配置

      <VirtualHost *:80>
      ServerName www.discuzx.com
      DocumentRoot "/vhost/discuzx/"
      <Directory "/vhost/discuzx/">
          Options None
          Allowoverride None
          require all granted
      </Directory>
      </VirtualHost>
      <VirtualHost *:80>
          ServerName www.wordpress.com
          DocumentRoot "/vhost/wordpress/"
          <Directory "/vhost/wordpress/">
              Options None
              Allowoverride None
              require all granted
          </Directory>
      </VirtualHost>
      <VirtualHost *:80>
          ServerName www.drupal.com
          DocumentRoot "/vhost/drupal/"
          <Directory "/vhost/drupal/">
              Options None
              Allowoverride None
              require all granted
          </Directory>
      </VirtualHost>

2.創建本地文件系統資源目錄

    ]# mkdir -pv /vhost/{discuzx,wordpress,drupal}/
    mkdir: created directory ‘/vhost’
    mkdir: created directory ‘/vhost/discuzx/’
    mkdir: created directory ‘/vhost/wordpress/’
    mkdir: created directory ‘/vhost/drupal/’

3.創建首頁
]# cd /vhost/
]# for i in `ls`; do echo "The page is $i" > /vhost/${i}/index.html ;done

    ]# tree
    .
    ├── discuzx
    │   └── index.html
    ├── drupal
    │   └── index.html
    └── wordpress
        └── index.html

4.檢查語法

    ]# httpd -t 
        Syntax OK

5.reload httpd服務
]# service httpd reload]# systemctl reload httpd
6.測試

(d) phpMyAdmin,此虛擬主機僅支持https協議;
1.CA自簽(192.168.33.67為https服務器,192.168.33.77主機為CA機構)
生成私鑰

    ]# (umask 077;openssl genrsa -out /etc/pki/CA/private/cakey.pem 4096)

生成自簽證書

    [root@ _21_ ~]# openssl req -x509 -new -key /etc/pki/CA/private/cakey.pem -out /etc/pki/CA/cacert.pem -days 365
    You are about to be asked to enter information that will be incorporated
    into your certificate request.
    What you are about to enter is what is called a Distinguished Name or a DN.
    There are quite a few fields but you can leave some blank
    For some fields there will be a default value,
    If you enter '.', the field will be left blank.
    -----
    Country Name (2 letter code) [XX]:CN
    State or Province Name (full name) []:Beijing
    Locality Name (eg, city) [Default City]:Beijing
    Organization Name (eg, company) [Default Company Ltd]:Magedu  
    Organizational Unit Name (eg, section) []:Opt
    Common Name (eg, your name or your server's hostname) []:www.gen.com
    Email Address []:gen@qq.com

為CA提供所需的文件及目錄

    [root@ _22_ ~]# mkdir -pv /etc/pki/CA/{certs,crl,newcerts}
    [root@ _23_ ~]# touch /etc/pki/CA/{serial,index.txt}
    [root@ _24_ ~]# echo 01 > /etc/pki/CA/serial

https服務器生成私鑰

    ]# mkdir /etc/httpd/ssl/
    ]# cd /etc/httpd/ssl
    [root@ _104_ /etc/httpd/ssl]# openssl req -new -key httpd.key -out httpd.csr -days 365
    You are about to be asked to enter information that will be incorporated
    into your certificate request.
    What you are about to enter is what is called a Distinguished Name or a DN.
    There are quite a few fields but you can leave some blank
    For some fields there will be a default value,
    If you enter '.', the field will be left blank.
    -----
    Country Name (2 letter code) [XX]:CN
    State or Province Name (full name) []:Beijing
    Locality Name (eg, city) [Default City]:Beijing
    Organization Name (eg, company) [Default Company Ltd]:Magedu
    Organizational Unit Name (eg, section) []:Opt
    Common Name (eg, your name or your server's hostname) []:www.phpmyadmin.com
    Email Address []:php@qq.com

    Please enter the following 'extra' attributes
    to be sent with your certificate request
    A challenge password []:
    An optional company name []:

    之后發送給CA主機簽署

CA主機簽署證書

    [root@ _38_ tmp]# openssl ca -in httpd.csr -out /root/httpd.crt -days 365
    兩次回答yes

把證書發送給提供https服務的主機

配置httpd支持使用ssl,及使用的證書

    ]# yum -y install mod_ssl
    ]# vim /etc/httpd/conf.d/ssl.conf
    <VirtualHost _default_:443>
        ServerName www.phpmyadmin.com
        DocumentRoot "/vhost/phpmyadmin/"
        <Directory "/vhost/phpmyadmin/">
            Options None
            AllowOverride None
            require all granted
        </Directory>

    SSLCertificateFile /etc/httpd/ssl/httpd.crt
    SSLCertificateKeyFile /etc/httpd/ssl/httpd.key

物理機IE瀏覽器訪問

導入CA證書到瀏覽器,然后訪問

  • 對phpMyAdmin首頁做壓力測試
    分別給出并發為10, 20, 50, 100, 200, 500等時的每秒響應數;

      [root@ _13_ ~]# ab -n 1000 -c 10 https://www.phpmyadmin.com/
      This is ApacheBench, Version 2.3 <$Revision: 655654 $>
      Copyright 1996 Adam Twiss, Zeus Technology Ltd, http://www.zeustech.net/
      Licensed to The Apache Software Foundation, http://www.apache.org/
    
      Benchmarking www.phpmyadmin.com (be patient)
      Completed 100 requests
      Completed 200 requests
      Completed 300 requests
      Completed 400 requests
      Completed 500 requests
      Completed 600 requests
      Completed 700 requests
      Completed 800 requests
      Completed 900 requests
      Completed 1000 requests
      Finished 1000 requests        
    
      Server Software:        Apache/2.4.6                #web服務器版本
      Server Hostname:        www.phpmyadmin.com            #服務器主機名
      Server Port:            443                            #服務器端口
      SSL/TLS Protocol:       TLSv1/SSLv3,ECDHE-RSA-AES256-GCM-SHA384,2048,256
    
      Document Path:          /                            #測試的頁面文檔
      Document Length:        23 bytes                    #文檔大小
    
      Concurrency Level:      10                            #并發數
      Time taken for tests:   24.976 seconds                #整個測試持續的時間
      Complete requests:      1000                        #完成的請求數
      Failed requests:        0                            #失敗的請求數
      Write errors:           0                            #請求寫入失敗的次數
      Total transferred:      304212 bytes                #所有傳輸量
      HTML transferred:       23092 bytes                    #所有html傳輸量
      Requests per second:    40.04 [#/sec] (mean)        #吞吐率,每秒事務數
      Time per request:       249.761 [ms] (mean)            #平均每個請求消耗的時間
      Time per request:       24.976 [ms] (mean, across all concurrent requests) #平均每個請求耗時/并發數
      Transfer rate:          11.89 [Kbytes/sec] received #平均每秒網絡上的流量
    
      Connection Times (ms)
                    min  mean[+/-sd] median   max            #網絡上消耗的時間分解
      Connect:       37  189  64.0    191     622
      Processing:     2   58  43.4     42     359
      Waiting:        0   42  36.4     29     335
      Total:         54  247  63.0    235     658
    
      Percentage of the requests served within a certain time (ms)
        50%    235                                        #整個場景中所有請求的響應情況,50%的用戶響應時間
        66%    249                                        #小于235毫秒,99%的用戶響應時間小于476毫秒
        75%    260
        80%    270
        90%    317
        95%    364
        98%    443
        99%    476
       100%    658 (longest request)
    
      并發為10
      ]# ab -n 1000 -c 10 https://www.phpmyadmin.com/
      Requests per second:    36.08 [#/sec] (mean)
    
      并發為20
      ]# ab -n 1000 -c 20 https://www.phpmyadmin.com/
      Requests per second:    35.97 [#/sec] (mean)
    
      并發為50
      ]# ab -n 1000 -c 50 https://www.phpmyadmin.com/
      Requests per second:    33.46 [#/sec] (mean)
    
      并發為100
      ]# ab -n 1000 -c 100 https://www.phpmyadmin.com/
      Requests per second:    33.61 [#/sec] (mean)
    
      并發為200
      ab -n 1000 -c 200 https://www.phpmyadmin.com/
      Requests per second:    32.52 [#/sec] (mean)
    
      并發為500
      ]# ab -n 1000 -c 500 https://www.phpmyadmin.com/
      Requests per second:    19.39 [#/sec] (mean)

原創文章,作者:M20-1--孔祥文,如若轉載,請注明出處:http://www.www58058.com/50704

(0)
M20-1--孔祥文M20-1--孔祥文
上一篇 2016-10-12
下一篇 2016-10-12

相關推薦

  • shell腳本編程之數組

    bash僅支持一維數組,類型聲明: declare -i    : 表示數值 declare -a  :表示普通數組(默認,可不用聲明類型) declare -A :表示關聯數組(必須聲明類型,bash需4.0以上版本才支持,可通過bash –version查看版本) 一、普通數組(用數字為下標) 1.1數組賦值(修…

    Linux干貨 2015-08-24
  • MariaDB數據類型總結

        數據類型是數據的一種屬性,它決定了數據的存儲格式、有效范圍及其它相應的限制。MariaDB的數據類型包括:字符型、整型、浮點值、日期時間型、布爾型及內建類型。 一、字符型     1、CHAR和VARCHAR類型     &nbsp…

    Linux干貨 2015-06-30
  • n25_第一周作業

    1.描述計算機的組成及其功能。 主要分為五個部分: 1. 控制器(Control):是整個計算機的中樞神經,其功能是對程序規定的控制信息進行解釋,根據其要求進行控制,調度程序、數據、地址,協調計算機各部分工作及內存與外設的訪問等。 2. 運算器(Datapath):運算器的功能是對數據進行各種算術運算和邏輯運算,即對數據進行加工處理。 3. 存儲器(Memo…

    Linux干貨 2016-12-01
  • 0804正則表達式作業

    用正則表達式表示IP地址         首先來分析一下,制IP地址是一個32位的二進制數,通常被分割為4個“8位二進制數”(也就是4個字節)。IP地址通常用“點分十進制”表示成(a.b.c.d)的形式,其中,a,b,c,d都是0~255之間的十進制整數。例:點分十進IP地址(1…

    Linux干貨 2016-08-10
  • 第六周作業補充-vim簡介及其使用方法詳細介紹

    What       Vim是由Vi發展出來的一個文本編輯器。代碼補全、編譯及錯誤跳轉等方便編程的功能特別豐富,在Unix& Unix Like操作系統中被廣泛使用。和Emacs并列成為Unix& Unix Like操作系統中最受歡迎的文本編輯器 When& Who  &nb…

    Linux干貨 2016-09-26
  • 一起學DHCP系列(一)開篇、概述

    原創作品,允許轉載,轉載時請務必以超鏈接形式標明文章 原始出處 、作者信息和本聲明。否則將追究法律責任。http://jeffyyko.blog.51cto.com/28563/162108     從本節開始,我們將開始討論有關DHCP服務器的相關問題,從易到難一步步理解DHCP服務。還是一樣,在…

    Linux干貨 2015-03-25
欧美性久久久久