2312123www 发表于 2016-5-26 08:56:25

LAMP-CentOS-7平台双机module模型

需求:
   CentOS 7 lamp (module)

       (1) 三者分离于两台主机
       (2) 一个虚拟主机用于提供phpMyAdmin;另一个虚拟机用于提供wordpress;
       (3) xcache
       (4) 为phpMyAdmin提供https虚拟主机


环境准备:
一:关闭selinux和iptables

1
2
setenforce 0
systemctl stop iptables





二:为了方便测试,修改本机hosts,也可自行搭建DNS Server

修改文件:

1
2
Linux:/etc/hosts
windows: \Windows\System32\drivers\etc\host




添加内容:

1
2
172.18.64.61 phpadmin.com
172.18.64.62 wordpress.com





实验环境:

1
2
3
host1: apache + php172.18.64.61
host2: mariadb      172.18.64.62
host3: 私有CA      172.18.64.63





Host 1

1
# yum install httpd php php-mysql -y




Host 2

1
2
3
4
5
6
7
8
9
# yum install mariadb-server
# systemctl start mariadb

mysql> create user 'root'@'172.18.64.%';
mysql> grant all on *.* to 'root'@'172.18.64.%' identified by '123456';      //phpadmin

mysql> create database wordpress;
mysql> create user 'wordpress'@'172.18.64.%';
mysql> grant all on wordpress.* to 'wordpress'@'172.18.64.%' identified by 'wordpress';   //wordpress





创建虚拟主机
一个虚拟机用于提供phpMyAdmin;另一个虚拟主机用于提供wordpress

Host1

一:注释/etc/httpd/conf/httpd.conf 第119行

1
# DocumentRoot "/var/www/html"




二:配置虚拟主机

mkdir -pv /www/host1/phpadmin wordpress

三:获取源码
phpadmin
官网:http://www.phpmyadmin.net

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
# cd /www/host1/phpadmin
# wget
# unzipphpMyAdmin-4.6.0-all-languages.zip
# mv phpMyAdmin-4.6.0-all-languages phpmyadmin
# cd phpmyadmin
# cp config.sample.inc.php config.inc.php

生成随机数
# openssl rand -base64 20
6rR4Nxjl7YEdSBXNQlxIMZ8TeVw

将生成的随机数添加到config.inc.php:
$cfg['blowfish_secret'] = 'Js/yatgOt2UBJMkKqkeJfFX9RKA';

指定数据库的IP地址
$cfg['Servers'][$i]['host'] = '10.0.0.62';





wordpress
官网:https://cn.wordpress.org

1
2
3
# cd /www/host1/wordpress
# wget
# unzip wordpress-4.5-zh_CN.tar.gz






压力测试
ab
   -n:总请求数
   -c:模拟并行数


1
2
# ab -n 100 -c 100 http://www.phpadmin.com/index.php
Requests per second:    70.21 [#/sec] (mean) // 每秒处理请求数 70.21





编译安装xcache
官网:http://xcache.lighttpd.net/

1
2
3
4
5
6
7
8
9
10
11
# yum install php-devel -y      //xcache依赖php-devel
# wget
# tar xf xcache-3.2.0.tar.bz2
# cd xcache-3.2.0
# phpiz
# ./configure --enable-xcache --with-php-config=`which php-config`
# make && make install
# cp xcache.ini /etc/php.d
# systemctl reload httpd

Requests per second:    377.42 [#/sec] (mean)       //性能提升五倍




注意epel源中xcache的rpm包可能有问题,性能不升反降



页: [1]
查看完整版本: LAMP-CentOS-7平台双机module模型