学习笔记

Study notes

Mac机下使用ab性能测试工具安装配置

云逐梦16682019-05-14 15:13:00返回列表

Mac机下使用ab性能测试工具安装配置过程

一、在mac机中配置apache

首先打开终端:

  1. 查看apache的版本:


    sudo apachectl -v

    image.png


  2. 启动apache

    sudo apachectl start

        然后在浏览器中输入"http://localhost/",将会看到如图所示
        image.png

    3.设置虚拟终端机

    打开apache的配置文件,命令如下:

sudo vi /etc/apache2/httpd.conf

    在httpd.conf中找到“#Include /private/etc/apache2/extra/httpd-vhosts.conf”,将“#”去掉,保存并退出,然后重启apache:

sudo apachectl restart


    4.打开配置虚拟主机文件httpd-vhost.conf,配置虚拟主机,命令如下:

 sudo vi /etc/apache2/extra/httpd-vhosts.conf


<VirtualHost *:80>
    ServerAdmin webmaster@dummy-host.example.com
    DocumentRoot "/usr/docs/dummy-host.example.com"
    ServerName dummy-host.example.com
    ServerAlias www.dummy-host.example.com
    ErrorLog "/private/var/log/apache2/dummy-host.example.com-error_log"
    CustomLog "/private/var/log/apache2/dummy-host.example.com-access_log" common
</VirtualHost>
<VirtualHost *:80>
    ServerAdmin webmaster@dummy-host2.example.com
    DocumentRoot "/usr/docs/dummy-host2.example.com"
    ServerName dummy-host2.example.com
    ErrorLog "/private/var/log/apache2/dummy-host2.example.com-error_log"
    CustomLog "/private/var/log/apache2/dummy-host2.example.com-access_log" common
</VirtualHost>



<VirtualHost *:80>
    DocumentRoot "/Library/WebServer/Documents"
    ServerName localhost
    ErrorLog "/private/var/log/apache2/localhost-error_log"
    CustomLog "/private/var/log/apache2/localhost-access_log" common
</VirtualHost>
<VirtualHost *:80>
    DocumentRoot "/Users/yun/Documents/la/public"
    ServerName www.la.com
    ErrorLog "/private/var/log/apache2/sites-error_log"
    CustomLog "/private/var/log/apache2/sites-access_log" common
<Directory />
            Options Indexes FollowSymLinks MultiViews
            AllowOverride None
            Order deny,allow
            Allow from all
  </Directory>
</VirtualHost>

前两个是默认开启的虚拟主机的例子,后面两个是新加的。然后保存退出,重启apache:

sudo apachectl restart


此时配置完成!!!


二、进行简单的压力测试

测试语句如下:

ab -n 10 -c 10  https://www.baidu.com/


-n请求数

-c并发数

后面是请求url链接

返回结果如图所示:


image.png



返回
顶部