设为首页 收藏本站
查看: 1156|回复: 0

LAMP之AMP分离+XCache加速

[复制链接]
累计签到:1 天
连续签到:1 天
发表于 2015-5-4 08:33:29 | 显示全部楼层 |阅读模式
搭建LAMP平台,要求apache、php、MariaDB分别在不同服务器实现动静分离,不需要考虑动态服务器和静态服务器数据同步问题;
在LAMP平台之上,搭建博客和论坛,博客和论坛分别位于不同主机;
公网用户除了可以访问httpd之外不能访问内网任何一台服务器;
部署完成使用ab命令进行压力测试,并且部署Xcache为php提供加速功能。

环境拓扑如下所示:
wKiom1VGL5SAiZl1AAIUw9uMFDM331.jpg

部署思路网络环境:
  Apache服务器使用双网卡,一块网卡监听外网用户请求,一块网卡和内网服务区进行通信,apache的内网网卡和其他服务器使用交换机进行连接。
Apache和php交互:
  Apache和php交互有三种方式,cgi,模块方式,fcgi;但是cgi和fcgi跨主机访问php服务器,所以apache和php服务器只能使用fcgi方式进行交互。
php和MariaDB交互:
  安装bbs和blog时,会要求提供MariaDB数据库和用户密码等信息,所以只需要在MariaDB数据创建好相关的数据库和用户,然后在保证php服务器可以访问即可。
bbs和blog安装问题:
  • 安装的程序包需要在apache和php服务器都存在一份,apache提供静态页面访问,php提供动态页面访问;不考虑同步问题
  • 如果出现要求对程序有写入权限,静态服务器设置apache的服务用户daemon对文件可写,动态服务器设置php-fpm的服务用户nobody对文件可写。


实验环境

系统版本
主机名
ip地址
Apache
Centos 6.6 64位
web-01
外网:eth0: 1.1.1.1
内网:eth1:172.16.4.100
论坛
Centos 6.6 64位
bbs-01
内网: eth0:172.16.4.101
博客
Centos 6.6 64位
blog-01
内网: eth0:172.16.4.102
数据库
Centos 6.6 64位
MariaDB-01
内网:eth0:172.16.4.136
使用软件
1
2
3
4
5
6
7
8
apr-1.5.0.tar.bz2
apr-util-1.5.3.tar.bz2
httpd-2.4.10.tar.bz2
mariadb-5.5.43-linux-x86_64.tar.gz
php-5.4.40.tar.bz2
wordpress-3.3.1-zh_CN.zip
xcache-3.2.0.tar.bz2
Discuz_7.2_FULL_SC_UTF8.zip



Apache配置解决依赖关系
1
2
3
4
5
6
7
8
9
10
11
12
13
14
yum -y groupinstall "Development tools""Desktop Platform Development"
yum -y install pcre-devel openssl-devel
  
tar xf apr-1.5.0.tar.bz2
cd apr-1.5.0
./configure --prefix=/usr/local/apr
make && make install
cd ..
  
tar xf apr-util-1.5.3.tar.bz2
cd apr-util-1.5.3
./configure --prefix=/usr/local/apr-util--with-apr=/usr/local/apr
make && make install
cd ..



编译安装httpd
1
2
3
4
tar xf httpd-2.4.10.tar.bz2
cd httpd-2.4.10
./configure --prefix=/usr/local/apache --sysconfdir=/etc/httpd24--enable-so --enable-ssl --enable-cgi --enable-rewrite --with-zlib --with-pcre--with-apr=/usr/local/apr --with-apr-util=/usr/local/apr-util/--enable-modules=most --enable-mpms-shared=all --with-mpm=event
make && make install



修改PATH变量,让系统可以直接找到http的命令路径
1
2
3
4
5
[iyunv@web-01 httpd-2.4.10]# vim/etc/profile.d/httpd.sh
export PATH=/usr/local/acaphe/bin:$PATH
[iyunv@web-01 httpd-2.4.10]# ./etc/profile.d/httpd.sh
[iyunv@web-01 httpd-2.4.10]# which httpd
/usr/local/apache/bin/httpd



设置启动脚本
1
2
3
4
5
6
7
8
9
[iyunv@web-01 httpd-2.4.10]# cp/usr/local/apache/bin/apachectl /etc/init.d/httpd24
[iyunv@web-01 httpd-2.4.10]# vim /etc/init.d/httpd24
#!/bin/sh
# chkconfig: 35 85 15      #设置服务识别参数,3、5级别启动,启动顺序85,关闭顺序15
# description: Apache   #服务描述信息
[iyunv@web-01 ~]# chkconfig --add httpd24
[iyunv@web-01 ~]# chkconfig --level 35 httpd24 on
[iyunv@web-01 ~]# chkconfig --list httpd24
httpd24          0:off  1:off  2:off  3:on   4:off  5:on   6:off



修改httpd配置文件设置监听的端口         
1
2
3
[iyunv@web01 ~]# vim /etc/httpd24/httpd.conf
Listen 1.1.1.1:80
Listen 172.16.4.100:80



启动服务并访问验证
1
2
3
4
[iyunv@web01 ~]# service httpd24 start
[iyunv@web01 ~]# netstat -lnt | grep 80
tcp       0      0 172.16.4.100:80             0.0.0.0:*                   LISTEN     
tcp       0      0 1.1.1.1:80                  0.0.0.0:*                   LISTE



wKioL1VGMQKSo82LAAC1vX-1jz4600.jpg

虚拟主机配置编辑主配置文件,注释中心主机,启用虚拟主机选项
1
2
3
[iyunv@web01 ~]# vim /etc/httpd24/httpd.conf
#DocumentRoot "/usr/local/apache/htdocs"  
Include /etc/httpd24/extra/httpd-vhosts.conf



设置虚拟主机
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
[iyunv@web01 ~]# vim/etc/httpd24/extra/httpd-vhosts.conf
<VirtualHost *:80>
   ServerName bbs.discuz.com
   DocumentRoot "/www/bbs"
   <Directory "/www/bbs">
      Options none
      AllowOverride none
      Require all granted
   </Directory>
    ErrorLog"/var/log/httpd/bbs-error-log"
    CustomLog"/var/log/httpd/bbs-access-log" common
</VirtualHost>
<VirtualHost *:80>
   ServerName blog.wordpress.com
   DocumentRoot "/www/blog"
   <Directory "/www/blog">
      Options none
      AllowOverride none
      Require all granted
   </Directory>
    ErrorLog"/var/log/httpd/blog-error-log"
    CustomLog"/var/log/httpd/blog-access-log" common
</VirtualHost>



设置虚拟主机目录
1
2
3
[iyunv@web01 ~]# mkdir -p /www/{bbs,blog}
[iyunv@web01 ~]# echo bbs > /www/bbs/index.html
[iyunv@web01 ~]# echo blog > /www/blog/index.html



访问测试虚拟主机
wKioL1VGMQLQ-VWMAAAzrFFltIs083.jpg
wKioL1VGMQKCA9G_AAA6J7o6Zxk504.jpg

MariaDB配置配置/dev/sda3为lvm分区

1
2
3
4
5
6
7
8
9
10
11
12
13
14
[iyunv@MariaDB-01 ~]# fdisk -l /dev/sda
  
Disk /dev/sda: 128.8 GB, 128849018880 bytes
255 heads, 63 sectors/track, 15665 cylinders
Units = cylinders of 16065 * 512 = 8225280 bytes
Sector size (logical/physical): 512 bytes / 512bytes
I/O size (minimum/optimal): 512 bytes / 512 bytes
Disk identifier: 0x000471dd
  
   DeviceBoot      Start         End      Blocks  Id  System
/dev/sda1  *           1          26      204800  83  Linux
Partition 1 does not end on cylinder boundary.
/dev/sda2              26        7859   62914560   8e  Linux LVM
/dev/sda3           7859       11775    31462303+ 8e  Linux LVM



创建逻辑卷
1
2
3
4
5
6
7
8
9
10
[iyunv@MariaDB-01 ~]# lvcreate /dev/sda3
[iyunv@MariaDB-01 ~]# vgcreate myvg /dev/sda3
[iyunv@MariaDB-01 ~]# lvcreate -L 15G -n mydata myvg
[iyunv@MariaDB-01 ~]# lvs
  LV     VG  Attr       LSize  Pool Origin Data%  Meta% Move Log Cpy%Sync Convert
  mydata myvg-wi-a----- 15.00g                                                   
  root   vg0 -wi-ao---- 20.00g                                                   
  swap   vg0 -wi-ao----  2.00g                                                   
  usr    vg0 -wi-ao---- 10.00g                                                   
  var    vg0 -wi-ao---- 20.00g



格式化并挂载
1
2
3
4
5
[iyunv@MariaDB-01 ~]# mkfs.ext4 /dev/myvg/mydata
[iyunv@MariaDB-01 ~]# vim /etc/fstab
/dev/myvg/mydata        /mydata                 ext4    defaults        0 0
[iyunv@MariaDB-01 ~]# mkdir /mydata
[iyunv@MariaDB-01 ~]# mount -a



创建MariaDB服务用户,并且设置数据目录的属主属组为服务用户
1
2
3
4
[iyunv@MariaDB-01 ~]# groupadd -r mysql
[iyunv@MariaDB-01 ~]# useradd -g mysql -r -s/sbin/nologin -M mysql
[iyunv@MariaDB-01 ~]# mkdir /mydata/data
[iyunv@MariaDB-01 ~]# chown -R mysql:mysql/mydata/data/



安装MariaDB并初始化
1
2
3
4
5
6
tar xf mariadb-5.5.43-linux-x86_64.tar.gz -C/usr/local/
cd /usr/local/
ln -sv mariadb-5.5.43-linux-x86_64/ mysql
cd mysql/
chown -R mysql:mysql .
scripts/mysql_install_db --user=mysql--datadir=/mydata/data/




为MariaDB提供主配置文件
1
2
3
4
5
[iyunv@MariaDB-01 mysql]# cpsupport-files/my-large.cnf /etc/my.cnf
[iyunv@MariaDB-01 mysql]# vim /etc/my.cnf
thread_concurrency = 2     #设置CPU核心数量乘以2
datadir = /mydata/data     #设置数据文件目录
innodb_file_per_table = 1  #使用inoodb引擎,每表一个表文件



为MariaDB提供启动脚本
1
2
3
4
5
[iyunv@MariaDB-01 mysql]# cpsupport-files/mysql.server /etc/rc.d/init.d/mysqld
[iyunv@MariaDB-01 mysql]# chkconfig --add mysqld
[iyunv@MariaDB-01 mysql]# chkconfig mysqld on
[iyunv@MariaDB-01 mysql]# chkconfig --list mysqld
mysqld           0:off  1:off  2:on   3:on   4:on   5:on   6:off



修改PATH环境变量,让系统直接使用MariaDB相关命令
1
2
3
[iyunv@MariaDB-01 ~]# vim /etc/profile.d/mysql.sh
export PATH=/usr/local/mysql/bin:$PATH
[iyunv@MariaDB-01 ~]# . /etc/profile.d/mysql.sh



启动测试
1
2
3
4
5
6
7
8
9
10
11
12
[iyunv@MariaDB-01 ~]# service mysqld start
Starting MySQL...                                         [  OK  ]
[iyunv@MariaDB-01 ~]# mysql
Welcome to the MariaDB monitor.  Commands end with ; or \g.
Your MariaDB connection id is 2
Server version: 5.5.43-MariaDB-log MariaDB Server
  
Copyright (c) 2000, 2015, Oracle, MariaDBCorporation Ab and others.
  
Type 'help;' or '\h' for help. Type '\c' to clearthe current input statement.
  
MariaDB [(none)]>




动态服务器blog配置Php-fpm配置编译安装php依赖于MariaDB的文件,但是不需要对MariaDB进行任何配置,只需要解压到指定目录即可。
解压MariaDB到指定位置
1
2
3
tar xf mariadb-5.5.43-linux-x86_64.tar.gz -C/usr/local/
cd /usr/local/
ln -sv mariadb-5.5.43-linux-x86_64/ mysql



安装php依赖软件包
1
yum -y install libmcrypt libmcrypt-devel mhashmhash-devel openssl-devel bzip2-devel



编译安装php
1
2
3
4
tar xf php-5.4.40.tar.bz2
cd php-5.4.40
./configure --prefix=/usr/local/php5--with-mysql=/usr/local/mysql --with-openssl--with-mysqli=/usr/local/mysql/bin/mysql_config --enable-mbstring --with-freetype-dir--with-jpeg-dir --with-png-dir --with-zlib --with-libxml-dir=/usr--enable-xml  --enable-sockets--enable-fpm --with-mcrypt --with-config-file-path=/etc --with-config-file-scan-dir=/etc/php.d--with-bz2
make && make install



为php提供配置文件
1
[iyunv@blog-01 php-5.4.40]# cp php.ini-production/etc/php.ini



为php-fpm提供配置文件
1
[iyunv@blog-01 php-5.4.40]# cp/usr/local/php5/etc/php-fpm.conf.default /usr/local/php5/etc/php-fpm.conf



为php-fpm提供启动脚本

1
2
3
4
[iyunv@blog-01 php-5.4.40]# cpsapi/fpm/init.d.php-fpm /etc/rc.d/init.d/php-fpm
[iyunv@blog-01 php-5.4.40]# chmod +x/etc/rc.d/init.d/php-fpm
[iyunv@blog-01 php-5.4.40]# chkconfig --add php-fpm
[iyunv@blog-01 php-5.4.40]# chkconfig php-fpm on



修改php-fpm设置
1
2
3
4
5
6
7
[iyunv@blog-01 php-5.4.40]# vim/usr/local/php/etc/php-fpm.conf
pm.max_children = 50         #每个进程的子进程数据
pm.start_servers = 5         #启动时开启的进程数
pm.min_spare_servers = 2     #最少空闲机舱内
pm.max_spare_servers = 8     #最多空闲进程
pid = /usr/local/php/var/run/php-fpm.pid
listen = 172.16.4.102:9000   #设置监听的地址,需要保证web服务器可以访问此地址。



启动并验证
1
2
3
4
[iyunv@blog-01 php-5.4.40]# service php-fpm start
[iyunv@blog-01 php-5.4.40]# netstat -lnt | grepphp-fpm
[iyunv@blog-01 php-5.4.40]# netstat -lnt | grep:9000
tcp       0      0 172.16.4.102:9000           0.0.0.0:*                   LISTEN



查看启动的进程
1
2
3
4
5
6
7
8
[iyunv@blog-01 ~]# ps aux | grep php-fpm
root     12569  0.0  0.0 103252  832 pts/0    S+   06:48  0:00 grep php-fpm
root     97811  0.0  0.4 155924 4084 ?        Ss   04:05  0:01 php-fpm: master process (/usr/local/php5/etc/php-fpm.conf)                                                                     
nobody   97812  0.0  2.5 175708 26068 ?        S   04:05   0:03 php-fpm: poolwww                                                                                                              
nobody   97813  0.0  2.5 175936 25992 ?        S   04:05   0:04 php-fpm: poolwww                                                                                                              
nobody   97814  0.0  2.1 170612 21372 ?        S   04:05   0:02 php-fpm: poolwww                                                                                                               
nobody   97815  0.0  2.0 170584 20980 ?        S   04:05   0:03 php-fpm: poolwww                                                                                                              
nobody   97816  0.0  2.0 168996 21084 ?        S   04:05   0:03 php-fpm: poolwww



apache的blog虚拟主机设置连接php配置httpd支持fcgi,修改主配置文件取消注释即可
1
2
LoadModule proxy_module modules/mod_proxy.so
LoadModule proxy_fcgi_module modules/mod_proxy_fcgi.so



修改虚拟主机配置,使所有php结尾的文件通通转发到后端的blog服务器
1
2
3
4
5
6
7
8
9
10
11
12
13
14
[iyunv@web01 ~]# vim/etc/httpd24/extra/httpd-vhosts.conf
<VirtualHost *:80>
   ServerName blog.wordpress.com
   DocumentRoot "/www/blog"
   <Directory "/www/blog">
      Options none
       AllowOverridenone
      Require all granted
   </Directory>
    ErrorLog"/var/log/httpd/blog-error-log"
    CustomLog"/var/log/httpd/blog-access-log" common
  ProxyRequests Off          #关闭正向代理
  ProxyPassMatch ^/(.*\.php)$ fcgi://172.16.4.102:9000/www/blog/$1   #访问php结尾的所有文件,转发给后端的php服务器
</VirtualHost>



设置完成重启httpd服务

blog服务器准备目录
1
[iyunv@blog-01 php-5.4.40]# mkdir -p /www/blog



放入测试页测试
1
2
3
4
[iyunv@blog-01 ~]# vim /www/blog/index.php
<?php
phpinfo();
?>



访问web服务器,web服务器看到访问的文件是php结尾,就将请求转发给了后端的blog服务器
wKiom1VGL5nyIhmPAAPy3Ka6o1E675.jpg
Blog服务器和MariaDB数据库连接MariaDB数据库创建blog的库和用户,并且授权用户对库有所有权限
1
2
MariaDB [mysql]> create database wordpress;
MariaDB [mysql]> GRANT all ON wordpress.* TO'wordpress'@'172.16.4.102' IDENTIFIED BY 'blogpasswd';




测试php和MariaDB的连接
测试页如下:
1
2
3
4
5
6
7
8
[iyunv@blog-01 ~]# vim /www/blog/index.php
<?php
$conn=mysql_connect('172.16.4.136','wordpress','blogpasswd');
  if ($conn)
   echo"连接数据库成功";
  else
   echo"连接数据库失败"
?>



wKiom1VGL5qSwYMCAAC83UQ995s322.jpg
安装blog
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
[iyunv@blog-01 ~]# unzip wordpress-3.3.1-zh_CN.zip
[iyunv@blog-01 ~]# mv wordpress/* /www/blog/
[iyunv@blog-01 ~]# cd /www/blog/
[iyunv@blog-01 blog]# cp wp-config-sample.phpwp-config.php
[iyunv@blog-01 blog]# vim wp-config.php
/** WordPress 数据库的名称 */
define('DB_NAME', 'wordpress');
  
/** MySQL 数据库用户名 */
define('DB_USER', 'wordpress');
  
/** MySQL 数据库密码 */
define('DB_PASSWORD', 'blogpasswd');
  
/** MySQL 主机 */
define('DB_HOST', '172.16.4.136');



web服务器需要为用户提供wordpress的静态文件
1
2
[iyunv@web01 ~]# mv wordpress/* /www/blog/
[iyunv@web01 ~]# unzip wordpress-3.3.1-zh_CN.zip



在blog服务器和web服务器都准备好静态文件之后,就可以进行安装了,打开浏览器输入,http://blog.wordpress.com/wp-admin/install.php即可安装。
wKioL1VGMQmi95ZWAALiaFSqFUo540.jpg
配置完成之后登录
wKioL1VGMRmRUiF3AAPXgy-8hjw701.jpg

动态服务器bbs配置Php-fpm配置解压MariaDB到指定位置
1
2
3
tar xf mariadb-5.5.43-linux-x86_64.tar.gz -C/usr/local/
cd /usr/local/
ln -sv mariadb-5.5.43-linux-x86_64/ mysql



安装php依赖软件包
1
yum -y install libmcrypt libmcrypt-devel mhashmhash-devel openssl-devel bzip2-devel



编译安装php
1
2
3
4
tar xf php-5.4.40.tar.bz2
cd php-5.4.40
./configure --prefix=/usr/local/php5--with-mysql=/usr/local/mysql --with-openssl --with-mysqli=/usr/local/mysql/bin/mysql_config--enable-mbstring --with-freetype-dir --with-jpeg-dir --with-png-dir--with-zlib --with-libxml-dir=/usr --enable-xml --enable-sockets --enable-fpm --with-mcrypt  --with-config-file-path=/etc--with-config-file-scan-dir=/etc/php.d --with-bz2
make && make install



为php提供配置文件
1
[iyunv@bbs-01 php-5.4.40]# cp php.ini-production/etc/php.ini



为php-fpm提供配置文件
1
[iyunv@bbs-01 php-5.4.40]# cp/usr/local/php5/etc/php-fpm.conf.default /usr/local/php5/etc/php-fpm.conf



为php-fpm提供启动脚本
1
2
3
4
[iyunv@bbs-01 php-5.4.40]# cp sapi/fpm/init.d.php-fpm/etc/rc.d/init.d/php-fpm
[iyunv@bbs-01 php-5.4.40]# chmod +x/etc/rc.d/init.d/php-fpm
[iyunv@bbs-01 php-5.4.40]# chkconfig --add php-fpm
[iyunv@bbs-01 php-5.4.40]# chkconfig php-fpm on



编辑php-fpm的配置文件
1
2
3
4
5
6
7
[iyunv@bbs-01 php-5.4.40]# vim /usr/local/php/etc/php-fpm.conf
pm.max_children = 50
pm.start_servers = 5
pm.min_spare_servers = 2
pm.max_spare_servers = 8
pid = /usr/local/php/var/run/php-fpm.pid
listen = 172.16.4.101:9000    #设置php-fpm监听的地址,保证web服务器可以访



问此地址

启动php-fpm
1
2
3
[iyunv@bbs-01 php-5.4.40]# service php-fpm start
[iyunv@bbs-01 php-5.4.40]# netstat -lnt | grep :9000
tcp       0      0 172.16.4.101:9000           0.0.0.0:*                   LISTEN



配置web服务器和bbs服务器连接虚拟主机设置,将php结尾的文件转发到后端的bbs服务器
1
2
3
4
5
6
7
8
9
10
11
12
13
<VirtualHost *:80>
   ServerName bbs.discuz.com
    DocumentRoot "/www/bbs"
   <Directory "/www/bbs">
      Options none
      AllowOverride none
      Require all granted
   </Directory>
    ErrorLog"/var/log/httpd/bbs-error-log"
    CustomLog"/var/log/httpd/bbs-access-log" common
   ProxyRequests Off
   ProxyPassMatch^/(.*\.php)$ fcgi://172.16.4.101:9000/www/bbs/$1
</VirtualHost>



验证apache和php的cfgi连接
1
2
3
4
[iyunv@bbs-01 ~]# vim /www/bbs/index.php
<?php
phpinfo();
?>



wKioL1VGMRuzmOBgAAOskENXx2o872.jpg
配置bbs服务器和MariaDB服务器连接创建数据库和数据库用户,并且授权用户对数据库具有全部权限
1
2
MariaDB [mysql]> create database bbsdb;
MariaDB [mysql]> GRANT all ON bbsdb.* TO 'runbbs'@'172.16.4.101' IDENTIFIED BY 'adm123';



测试php和mysql的连接
修改测试页面
1
2
3
4
5
6
7
8
9
10
11
12
[iyunv@bbs-01 ~]# vim /www/bbs/index.php
<?php
$conn=mysql_connect('172.16.4.136','runbbs','adm123');
  if ($conn)
   echo"连接数据库成功";
  else
   echo"连接数据库失败"
?>
  
<?php
phpinfo();
?>



wKiom1VGL6-yFNJ6AADEXkNLnZU665.jpg

部署论坛将Discuz的程序文件解压,并且将upload中所有文件放置到网站目录
1
2
[iyunv@bbs-01 ~]# unzip Discuz_7.2_FULL_SC_UTF8.zip-d Discuz
[iyunv@bbs-01 ~]# mv Discuz/upload/* /www/bbs/



设置php-fpm的服务用户为下面文件的属主或者对其设置写权限,否则安装时会报错
1
2
3
[iyunv@bbs-01 ~]# cd /www/bbs/
[iyunv@bbs-01 bbs]# chown -R nobody templates/attachments/ forumdata/
[iyunv@bbs-01 bbs]# chown -R nobodyuc_client/data/cache/ config.inc.php



web服务器也需要有静态文件
1
2
[iyunv@web01 ~]# mv Discuz/upload/* /www/bbs/
[iyunv@web01 ~]# unzip Discuz_7.2_FULL_SC_UTF8.zip-d Discuz



设置httpd的服务用户对指定文件也需要有写权限
1
2
3
[iyunv@web01 ~]# cd /www/bbs/
[iyunv@web01 bbs]# chown -R daemon templates/attachments/ forumdata/
[iyunv@web01 bbs]# chown -R daemonuc_client/data/cache/ config.inc.php



设置完成之后,输入httd://bbs.discuz.com/install即可安装
wKioL1VGMR-Aaj6jAAIgz47432Q341.jpg

只需要根据错误提示进行排除即可
1
2
3
[iyunv@bbs-01 bbs]# vim /etc/php.ini
short_open_tag = ON
[iyunv@bbs-01 bbs]# service php-fpm restart



排错之后继续访问安装目录,就可以继续安装了
wKioL1VGMSLAhCY2AARIpa7Tr74715.jpg
填写数据库的相关信息,添加数据库服务器的地址和MariaDB创建的数据库和用户密码,而后在设置bbs的管理员帐号密码就可以继续安装了。
wKiom1VGL7eyPSu7AANN5CkctUg615.jpg
剩下的根据提示安装即可。
wKioL1VGMSbAagloAAJEvDr-sh0445.jpg

出现上面这种情况是由于php服务器安装了discuz之后导致程序发生变化从而导致动态服务器和静态服务器的程序不一致,只需要手动把bbs服务器的文件和web服务器进行一次同步即可,如果想实现自动同步,需要使用其他服务,如initory+rsync、sersync等工具。
1
[iyunv@bbs-01 bbs]# scp -r *root@172.16.4.100:/www/bbs/



动态服务器和静态服务器同步文件之后,再次访问bbs的网址就正常了。
wKioL1VGMSmhghlFAAOkAclZhY4011.jpg

压力测试
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
[iyunv@client ~]# ab -n 3000 -c 100 httpd://www.discuz.com/index.php
省略部分内容……
  
Server Software:        Apache/2.4.10
Server Hostname:        bbs.discuz.com
Server Port:            80
  
Document Path:          /index.php
Document Length:        7691 bytes
  
Concurrency Level:      100
Time taken for tests:   58.782 seconds
Complete requests:      3000
Failed requests:        2137
   (Connect:0, Receive: 0, Length: 2137, Exceptions: 0)
Write errors:           0
Non-2xx responses:      29
Total transferred:      23679924 bytes
HTML transferred:       22723414 bytes
Requests per second:    51.04 [#/sec] (mean)    #每秒可以处理请求
Time per request:       1959.391 [ms] (mean)
Time per request:       19.594 [ms] (mean, across all concurrentrequests)
Transfer rate:          393.40 [Kbytes/sec] received
  
Connection Times (ms)
             min  mean[+/-sd] median   max
Connect:       0    2  10.2     0     135
Processing:  142 1926 1621.3   1355   31212
Waiting:     141 1924 1620.6   1354   31212
Total:       195 1928 1620.6   1356   31212
  
Percentage of the requests served within a certaintime (ms)
  50%   1356
  66%   1717
  75%   2312
  80%   2482
  90%   2945
  95%   4149
  98%   6231
  99%   9875
100%  31212 (longest request)





部署xcache为php加速编译安装Xcache
1
2
3
4
5
tar xf xcache-3.2.0.tar.bz2
cd xcache-3.2.0
/usr/local/php5/bin/phpize
./configure --enable-xcache--with-php-config=/usr/local/php5/bin/php-config
make && make install



安装结束会出现如下行
Installing shared extensions:    /usr/local/php5/lib/php/extensions/no-debug-non-zts-20100525/
整合php和xcache,将XCache配置文件复制到php.d目录下,使php可以读取XCache配置文件
1
2
[iyunv@bbs-01 xcache-3.2.0]# mkdir /etc/php.d
[iyunv@bbs-01 xcache-3.2.0]# cp xcache.ini/etc/php.d/



接下来编辑/etc/php.d/xcache.ini,找到zend_extension开头的行,修改为如下行
1
zend_extension =/usr/local/php5/lib/php/extensions/no-debug-non-zts-20100525/xcache.so



设置完成之后,重启php-fpm服务。
在bbs网页目录准备php测试页面,访问如果出现Xcache的内容说明Xcache安装成功
wKiom1VGL73BhnLFAAPD0Jb-tOA041.jpg

在次进行压力测试
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
[iyunv@client ~]# ab -n 3000 -c 100http://bbs.discuz.com/index.php
省略部分内容…………
  
Server Software:        Apache/2.4.10
Server Hostname:        bbs.discuz.com
Server Port:            80
  
Document Path:          /index.php
Document Length:        7687 bytes
  
Concurrency Level:      100
Time taken for tests:   9.983 seconds
Complete requests:      3000
Failed requests:        0
Write errors:           0
Total transferred:      24031128 bytes
HTML transferred:       23061000 bytes
Requests per second:    300.51 [#/sec] (mean)   
Time per request:       332.762 [ms] (mean)
Time per request:       3.328 [ms] (mean, across all concurrentrequests)
Transfer rate:          2350.82 [Kbytes/sec] received
  
Connection Times (ms)
              min  mean[+/-sd] median   max
Connect:       0    1   3.9     0      25
Processing:   31  327  45.2   328     701
Waiting:      31  327  45.2   327     701
Total:        42  328  43.4   328     701
  
Percentage of the requests served within a certaintime (ms)
  50%    328
  66%    339
  75%    346
  80%    354
  90%    378
  95%    391
  98%    417
  99%    428
100%    701 (longest request)



通过对比安装Xcache前后的压力测试结果,可以看出处理的请求数由每秒处理50个请求提升到了300个,当然由于是本机进行测试,没有考虑带宽的因素,所以性能稍高。


运维网声明 1、欢迎大家加入本站运维交流群:群②:261659950 群⑤:202807635 群⑦870801961 群⑧679858003
2、本站所有主题由该帖子作者发表,该帖子作者与运维网享有帖子相关版权
3、所有作品的著作权均归原作者享有,请您和我们一样尊重他人的著作权等合法权益。如果您对作品感到满意,请购买正版
4、禁止制作、复制、发布和传播具有反动、淫秽、色情、暴力、凶杀等内容的信息,一经发现立即删除。若您因此触犯法律,一切后果自负,我们对此不承担任何责任
5、所有资源均系网友上传或者通过网络收集,我们仅提供一个展示、介绍、观摩学习的平台,我们不对其内容的准确性、可靠性、正当性、安全性、合法性等负责,亦不承担任何法律责任
6、所有作品仅供您个人学习、研究或欣赏,不得用于商业或者其他用途,否则,一切后果均由您自己承担,我们对此不承担任何法律责任
7、如涉及侵犯版权等问题,请您及时通知我们,我们将立即采取措施予以解决
8、联系人Email:admin@iyunv.com 网址:www.yunweiku.com

所有资源均系网友上传或者通过网络收集,我们仅提供一个展示、介绍、观摩学习的平台,我们不对其承担任何法律责任,如涉及侵犯版权等问题,请您及时通知我们,我们将立即处理,联系人Email:kefu@iyunv.com,QQ:1061981298 本贴地址:https://www.yunweiku.com/thread-63320-1-1.html 上篇帖子: LAMP安装 下篇帖子: LAMP平台源码搭建
您需要登录后才可以回帖 登录 | 立即注册

本版积分规则

扫码加入运维网微信交流群X

扫码加入运维网微信交流群

扫描二维码加入运维网微信交流群,最新一手资源尽在官方微信交流群!快快加入我们吧...

扫描微信二维码查看详情

客服E-mail:kefu@iyunv.com 客服QQ:1061981298


QQ群⑦:运维网交流群⑦ QQ群⑧:运维网交流群⑧ k8s群:运维网kubernetes交流群


提醒:禁止发布任何违反国家法律、法规的言论与图片等内容;本站内容均来自个人观点与网络等信息,非本站认同之观点.


本站大部分资源是网友从网上搜集分享而来,其版权均归原作者及其网站所有,我们尊重他人的合法权益,如有内容侵犯您的合法权益,请及时与我们联系进行核实删除!



合作伙伴: 青云cloud

快速回复 返回顶部 返回列表