标签:httpd 虚拟主机 压力测试 测试结果
(1) CentOS 7, apm+xcache, rpm包, phpmodule;
a)一个虚拟主机提供phpMyAdmin,另一个虚拟主机提供wordpress;
b)为phpMyAdmim提供https服务;
(2) CentOS 7, amp + xcache, rpm包,php-fpm;
a)httpd, php, mariadb分别部署在一个单独的主机上;
b)一个虚拟主机提供phpMyAdmin,另一个虚拟主机提供wordpress;
c)为phpMyAdmim提供https服务;
(3) 对以上所有部署做压力测试,并对比测试结果,写出测试报告;
Server规划
CentOS71(172.16.126.1) httpd+php+mariadb
CentOS72(172.16.126.3192.168.0.72) php-fpm
CentOS73(192.168.0.74) mariadb
(1).
a).安装相应软件(Cent71):
[CentOS71:~]yuminstall httpd mod_ssl
[CentOS71:~]yuminstall php php-mysql php-mbstring php-xcache
[CentOS71:~]yuminstall mariadb mariadb-server
[CentOS71:~]ls/var/www/html
drwxr_xr_x…………………………………………….wordpress
drwxr_xr_x……………………………………………..phpMyAdmin
[CentOS71:~]rm–f /etc/httpd/cond.f/ssl.conf
b).配置文件:
[CentOS71:~]cat/etc/httpd/conf.d/vhost.conf
Listen443
<VirtualHost 172.16.126.1:443>
ServerName www.pma.magedu.com
DocumentRoot /data/web/www1
SSLENGINE on
SSLCertificateFile /etc/httpd/CA/cacert.pem
SSLCertificateKeyFile/etc/httpd/CA/cakey.pem
#密钥证书在上一博客有申请
<Directory /data/web/www1 >
Options ALL
AllowOverride none
Require all granted
</Directory>
</VirtualHost>
<VirtualHost 172.16.126.1:80>
ServerName www.wordpress.magedu.com
DocumentRoot /data/web/www1
<Directory /data/web/www1>
Options ALL
AllowOverride none
Require all granted
</Directory>
</VirtualHost>
[CentOS71:~]systemctlstart httpd
[CentOS71:~]systemctlstart mariadb
[CentOS71:~]mysql
Mariadb[none]>createdatabase wordpress
Mariadb[none]>grantall on wordpress.* ‘testuser’@’172.16.%.%’ identified by ‘password’
Mariadb[none]>\q
[CentOS71:~]-----文件/data/web/www1/wordpress/wp-config.php修改
define(‘DB_NAME‘, ‘wordpress‘);
define(‘DB_USER‘, ‘testuser‘);
define(‘DB_PASSWORD‘, ‘passwrod‘);
define(‘DB_HOST‘, ‘172.16.126.1‘);
[CentOS71:~]---------文件 /data/web/www1/phpMyAdmin/libraries/config.default.php修改
$cfg[‘blowfish_secret‘]= ‘HmVGDMOPXOSH2xH‘;
$cfg[‘Servers‘][$i][‘host‘]= ‘172.16.126.1‘;
$cfg[‘Servers‘][$i][‘port‘]= ‘3306‘;
############################ok
2).
a).安装软件与配置
[CentOS71:~]echo–e “ProxyRequests off\nProxyPassMatch ^/(.*\.php)$ fcgi://172.16.126.3:9000/data/web/www1\n”>> /etc/httpd/conf.d/vhost.conf
[CentOS73:~]yuminstall mariabd mariadb-server
[CentOS73:~]systemctlstart mariadb
[CentOS73:~]mysql
Mariadb[none]>createdatabase wordpress
Mariadb[none]>grantALL on wordpres.* to ‘testuser’@’192.168.0.%’ identified by ‘passwrod’
Mariadb[none]>\q
[CentOS72:~]yuminstall php-fpm php-mysql php-mbstring php-mysql
[CentOS72:~]----文件/etc/php-fpm.d/www.conf中
listen= 172.16.126.3:9000
listen.allowed_clients= 172.16.126.1
[CentOS72:~]tail-2 /etc/php-fpm.d/www.conf
php_value[session.save_handler]= files
php_value[session.save_path] = /var/lib/php/session
[CentOS72:~]mkdir/var/lib/php/session
[CentOS72:~]chonwapache:apache /var/lib/php/session
[CentOS72:~]
[CentOS72:~]mkdir–p /data/web~
[CentOS72:~]scproot@172.16.126.1:/data/web/www1/data/web/
[CentOS71:~]-----文件/data/web/www1/wordpress/wp-config.php修改
define(‘DB_NAME‘, ‘wordpress‘);
define(‘DB_USER‘, ‘testuser‘);
define(‘DB_PASSWORD‘, ‘passwrod‘);
define(‘DB_HOST‘, ‘192.168.0.74‘);
[CentOS71:~]---------文件 /data/web/www1/phpMyAdmin/libraries/config.default.php修改
$cfg[‘blowfish_secret‘]= ‘HmVGDMOPXOSH2xH‘;
$cfg[‘Servers‘][$i][‘host‘]= ‘192.168.0.74‘;
$cfg[‘Servers‘][$i][‘port‘]= ‘3306‘;
[CentOS71:~]systemctlstart php-fpm
################################ok
Point 测试脚本:
[CentOS674:~]cat netyali
#!/bin/bash
#usage netyali [url] [file]
#url 测试url如:http://172.16.126.1/index.php
#file 数据保存的路径
for i in 1 2 4 8 16 32 64 128
do
forj in 10 100 200 500 1000 1500 2000 25003000 4000
do
if[ $i -le $j ]; then
/usr/local/apache24/bin/ab-c $i -n $j $1 |sed -r -e ‘/^$/d‘ -e‘/^[[:space:]]/d‘ |tail -n +5|head -16|tr -s " "|gawk -F:‘{ printf("%s\t",$2)}END{print}‘ >>$2
fi
done
done
#####测试https时 将head -16 中的16 改成17 因为ab多了一条SLLprotocol
[CentOS674:~]----数据格式化命令:gawk-F "\t" ‘{for(i=1;i<NF;i++){split($i,a," "); b[i]=a[1]}for (j in b){printf("%s ",b[j])} printf("\n")}‘
#注意命令的数据左右位置和ab命令上下位置不一致 每次测试出75条记录
[CentOS71:~]cat/data/web/www1/inde.php
172.16.126.1
<?php
$conn= mysql_connect(‘172.16.126.1‘,‘testuser‘,‘mageedu‘);
if($conn)
echo" 172.16.126.1 OK";
else
echo"172.16.126.1 Failure";
?>
<?php
phpinfo();
?>
[CentOS72:~] cat /data/web/www1/inde.php
172.16.126.3
<?php
$conn =mysql_connect(‘192.168.0.74‘,‘testuser‘,‘mageedu‘);
if($conn)
echo "192.168.0.74 OK";
else
echo "192.168.0.74Failure";
?>
<?php
phpinfo();
?>
详细测试数据如下和附件(有具体数据和图示)
标签:httpd 虚拟主机 压力测试 测试结果
原文地址:http://9665476.blog.51cto.com/9655476/1827566