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.178linux.com/50704

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

相关推荐

  • 系统启动流程相关概念

    前言: 了解系统内核基本知识 内核功能:进程管理、内存管理、网络协议栈、文件系统、驱动程序、安全功能等  用户空间:应用程序其中有进程或者线程 运行中的系统可分为两层:内核空间、用户空间  内核设计流派:  单内核设计:把每种功能集成于一个程序中;例如:linux 微内核设计:每种功能使用一个单独的子系统实现;例如:Window…

    Linux干货 2016-09-19
  • N22-第五周作业

    1、显示当前系统上root、fedora或user1用户的默认shell;  egrep "^(root|fedora|user1)" /etc/passwd|awk -F: '{printf "%-15s:%-s\n",$1,$7}' 2…

    Linux干货 2016-09-15
  • linux基础2

    linux基础2

    Linux干货 2018-03-18
  • bash的基础特性[更新中]

    2、bash的工作特性之命令执行状态返回值和命令行展开所涉及的内容及其示例演示。
    3、请使用命令行展开功能来完成以下练习:
    (1)、创建/tmp目录下的:a_c, a_d, b_c, b_d
    (2)、创建/tmp/mylinux目录下的:
    mylinux/
    ├── bin
    ├── boot
    │   └── grub
    ├── dev
    ├── etc
    │   ├── rc.d
    │   │   └── init.d
    │   └── sysconfig
    │   └── network-scripts
    ├── lib
    │   └── modules
    ├── lib64
    ├── proc
    ├── sbin
    ├── sys
    ├── tmp
    ├── usr
    │   └── local
    │   ├── bin
    │   └── sbin
    └── var
    ├── lock
    ├── log
    └── run
    5、如何定义一个命令的别名,如何在命令中引用另一个命令的执行结果?
    6、显示/var目录下所有以l开头,以一个小写字母结尾,且中间至少出现一位数字(可以有其它字符)的文件或目录。
    7、显示/etc目录下,以任意一个数字开头,且以非数字结尾的文件或目录。
    8、显示/etc目录下,以非字母开头,后面跟了一个字母以及其它任意长度任意字符的文件或目录。
    9、在/tmp目录下创建以tfile开头,后跟当前日期和时间的文件,文件名形如:tfile-2016-05-27-09-32-22。
    10、复制/etc目录下所有以p开头,以非数字结尾的文件或目录到/tmp/mytest1目录中。
    11、复制/etc目录下所有以.d结尾的文件或目录至/tmp/mytest2目录中。
    12、复制/etc/目录下所有以l或m或n开头,以.conf结尾的文件至/tmp/mytest3目录中。

    2018-03-17
  • 马哥教育网络班22期+第三周课程练习

    1、列出当前系统上所有已经登录的用户的用户名,注意:同一个用户登录多次,则只显示一次即可。 [xw@localhost ~]$ who | cut -d' ' -f1 | uniq xw root 2、取出最后登录到当前系统的用户的相关信息。 [xw…

    Linux干货 2016-09-01
  • Linux 文本编辑器三剑客之 sed

    参考手册: http://www.gnu.org/software/sed/manual/sed.html 转载请注明:马哥教育!!

    Linux干货 2017-01-12