安装要求:
(1) 三者分离于三台主机
(2) 一个虚拟主机用于提供PHPMyAdmin;另一个虚拟主机用于提供wordpress;
(3) xcache
IP | 系统 | 软件 |
192.168.1.103 |
CentOS 7 | httpd |
192.168.1.104 | CentOS 7 | PHP-fpm,PHP-MysqL,,xcache |
192.168.1.105 | CentOS 7 | mariadb |
1、192.168.1.103 安装配置httpd
1)安装配置httpd
[root@localhost ~]# yum install httpd -y
[root@localhost ~]# vim /etc/httpd/conf/httpd.conf
#DocumentRoot "/var/www/html" //注释web默认访问路径
[root@localhost ~]# mkdir /apps/vhosts/b.net -pv //创建虚拟主机wordpress访问页面
[root@localhost ~]# mkdir /apps/vhosts/c.org -pv //创建虚拟主机PHPMyAdmin访问页面
2)基于虚拟主机配置
[root@localhost ~]# vim /etc/httpd/conf.d/vhosts.conf //创建并配置虚拟主机的配置文件
2、192.168.1.104安装配置 PHP-fpm ,PHP-MysqL
1)安装配置PHP-fpm
[root@localhost ~]# rpm -q PHP //确保没有装载PHP包
package PHP is not installed
[root@localhost ~]# yum install PHP-fpm PHP-MysqL PHP-mbstring -y
[root@localhost ~]# vim /etc/PHP-fpm.d/www.conf
listen = 192.168.1.104:9000 //修改PHP服务器监听地址
listen.allowed_clients = 192.168.1.103 //监听的httpd服务器地址
[root@localhost ~]# mkdir /var/lib/PHP/session //创建session目录
[root@localhost ~]# chown apache.apache /var/lib/PHP/session
[root@localhost ~]# ls -ld /var/lib/PHP/session
drwxr-xr-x 2 apache apache 6 Jun 2 22:53 /var/lib/PHP/session
[root@localhost ~]# systemctl start PHP-fpm.service
2) 创建httpd服务器连接PHP服务器的测试页
[root@localhost ~]# mkdir /apps/vhosts/b.net -pv
[root@localhost ~]# mkdir /apps/vhosts/c.org -pv
[root@localhost ~]# vim /apps/vhosts/b.net/index.PHP //虚拟主机www.b.net主机测试页
[root@localhost ~]# vim /apps/vhosts/c.org/index.PHP //虚拟主机www.c.org主机测试页
3)windows物理机添加虚拟主机的解析
4)windows浏览器进行验证httpd服务器与PHP服务器的连接
通过访问浏览器,证明httpd服务器与PHP服务器的连接是正常的。
3、192.168.1.105主机安装配置mariadb
1)安装mariadb服务器
[root@localhost ~]# yum install mariadb mariadb-server -y
[root@localhost ~]# vim /etc/my.cnf
skip_name_resolve=ON //在[MysqLd]下添加
[root@localhost ~]# systemctl start mariadb.service
[root@localhost ~]# MysqL
MariaDB [(none)]> GRANT ALL ON wpdb.* TO wpuser@'192.168.%.%' IDENTIFIED BY 'wppass'; //授权wordpress用户
MariaDB [(none)]> FLUSH PRIVILEGES;
MariaDB [(none)]> CREATE DATABASE pma; //创建PHPMyAdmin数据库
Query OK,1 row affected (0.00 sec)
MariaDB [(none)]> GRANT ALL ON pma.* TO pma@'192.168.%.%' IDENTIFIED BY 'pmapass';
MariaDB [(none)]> FLUSH PRIVILEGES;
[root@localhost ~]# vim /apps/vhosts/b.net/index.PHP
[root@localhost ~]# vim /apps/vhosts/c.org/index.PHP
4)windows浏览器进行验证PHP服务器与MysqL服务器的连接
至此,httpd服务器、PHP服务器和mariadb服务器三者之间证明可以正常通信。
1)下载解压PHPMyAdmin
[root@localhost vhosts]# cd /apps/vhosts/c.org
[root@localhost c.org]# ls
PHPMyAdmin-4.4.14.1-all-languages.zip //下载PHPMyAdmin压缩包(https://www.phpmyadmin.net/downloads/)
[root@localhost c.org]# unzip PHPMyAdmin-4.4.14.1-all-languages.zip
[root@localhost c.org]# mv PHPMyAdmin-4.4.14.1-all-languages pma
[root@localhost c.org]# cd pma
[root@localhost pma]# mv config.sample.inc.PHP config.inc.PHP
2)配置PHPMyAdmin
[root@localhost pma]# openssl rand -base64 15 //生成一段随机数
Q6UQjkqqkH758gITfS45
[root@localhost pma]# vim config.inc.PHP //编辑配置文件
[root@localhost c.org]# scp -r pma root@192.168.1.103:/apps/vhosts/c.org/
//此时需要把PHP主机的pma文件放到httpd主机的页面访问路径下
3)httpd主机
[root@localhost ~]# httpd -t //测试语法
Syntax OK
[root@localhost ~]# systemctl restart httpd.service
4)windows浏览器访问 www.c.org/pma
5、下载安装配置wordpress
1)下载解压wordpress
[root@localhost conf.d]# cd /apps/vhosts/b.net/
[root@localhost b.net]# ls //下载wordpress压缩包(下载地址:https://wordpress.org/download/)
wordpress-4.3.1-zh_CN.zip
[root@localhost b.net]# unzip wordpress-4.3.1-zh_CN.zip
[root@localhost b.net]# cd wordpress/
[root@localhost wordpress]# mv wp-config-sample.PHP wp-config.php
[root@localhost wordpress]# vim wp-config.php
[root@localhost b.net]# scp -r wordpress root@192.168.1.103:/apps/vhosts/b.net/ //此时需要把PHP主机的wordpress文件放到httpd主机的页面访问路径下
2)httpd主机
[root@localhost ~]# httpd -t //测试语法
Syntax OK
[root@localhost ~]# systemctl restart httpd.service
3)windows浏览器访问www.b.net/wordpress
6、PHP服务器安装xcache(配置好CentOS 7的epel源)
1)未装xcache之前,压力测试 http://www.b.net/index.php
[root@localhost ~]# ab -c 100 -n 1000 http://www.b.net/index.PHP
2)安装xcache
[root@localhost ~]# yum install PHP-xcache -y
[root@localhost ~]# systemctl restart PHP-fpm.service
3)进行压力测试
[root@localhost ~]# ab -c 100 -n 1000 http://www.b.net/index.PHP
通过安装xcache,发现压力测试效果还是有提升的,我这里只是测试了几次,平时压力测试需要多次测试进行比较。
原文链接:https://www.f2er.com/centos/382137.html