1.A主机的IP 是172.16.25182.,B主机的IP是172.16.251.154,C主机的IP是eth1 172.16.254.35。1. 在A、B、C三台主机上分别安装httpd、php-fpm、MariaDB。
(1)在A主机上安装httpd
~]# yum install -y httpd
(2)在B主机上安装php-fpm
~]# yum install -y php-fpm php-mysql
(3)在C主机上安装MariaDB
~]# yum install -y mariadb-server
2.编辑B主机的配置文件/etc/php-fpm.d/www.conf并重启php-fpm服务:
listen = 172.16.251.154:9000
listen.backlog = -1
listen.allowed_clients = 172.16.251.82
pm = dynamic
pm.max_children = 50
pm.start_servers = 5
pm.min_spare_servers = 5
pm.max_spare_servers = 35
pm.max_requests = 500
php_value[session.save_handler] = files
php_value[session.save_path] =/var/lib/php/session
同时需要手动创建目录/var/lib/php/session,并修改其属主和属组为apache
chown apache.apache /var/lib/php/session
3.启动php-fpm
~]# systemctl start php-fpm.service
4.在A主机上将/etc/httpd/conf.d/welcome.conf改名,然后创建两个基于FQDN的虚拟主机www1.magedu.com和www2.magedu.com.
(1)~]# mv/etc/httpd/conf.d/welcome.conf{,.bak}
(2)编辑www1主机的配置文件/etc/httpd/conf.d/www1.conf并重载httpd服务:
<VirtualHost 172.16.251.82:80>
ServerName www1.magedu.com
DocumentRoot /data/www1
ProxyRequests Off
DirectoryIndex index.php
ProxyPassMatch ^/(.*\.php)$ fcgi://172.16.251.154:9000/data/www1/$1
<Directory "/data/www1">
Options None
AllowOverride None
Require all granted
</Directory>
</VirtualHost>
(3)编辑www2主机的配置文件/etc/httpd/conf.d/www2.conf并重载httpd服务:
<VirtualHost 172.16.251.82:80>
ServerName www2.magedu.com
DocumentRoot /data/www2
ProxyRequests Off
DirectoryIndex index.php
ProxyPassMatch ^/(.*\.php)$ fcgi://172.16.251.154:9000/data/www2/$1
<Directory "/data/www1">
Options None
AllowOverride None
Require all granted
</Directory>
</VirtualHost>
5.测试
6.测试php-fpm与MariaDB的连接。
(1)在MariaDB中创建数据库testdb,用户testuser,密码testpasswd.
~]# mysql
MariaDB[(none)]>CREATEDATABASE testdb;
MariaDB[(none)]>CREATEUSER ‘testuser’@’172.16.%.%’ IDENTIFIED BY ‘testpasswd’;
MariaDB[(none)]>GRANTALL ON testdb.* TO ‘testuser’@’172.16.%.%’;
MariaDB[(none)]>FLUSHPRIVILEGES;
(2)在B主机上分别编辑/data/www1和/data/www2里面的index.php文件测试与MariaDB的连接是否正常,内容如下:
<?php
$conn= mysql_connect(‘172.16.254.35’,’testuesr’,’testpasswd’);
If($conn)
echo“OK”;
else
echo“Falure”;
?>
(3)在IE浏览器上测试如下:
7.在B主机上为虚拟主机www1上安装wordpress。
(1)将wordpress解压后放在/data/www1/目录下
~]# unzipwordpress_4.3.1_zh_CN.zip
(2)将该目录下wp-config-sample.php改名为wp-config.php并编辑以下内容:
~]# mv/data/www1/wp-config-sample.php /data/www1/wp-config.php
(3)在浏览器上打开www1.magedu.com测试。
8.在B主机上为虚拟主机www2安装phpMyAdmin.
(1)将phpMyAdmin解压并复制到/data/www2/目录下。
~]# cp -rphpMyAdmin-4.4.15.7-all-languages/* /data/www2/
(2)将config.sample.inc.php改名为config.inc.php
~]# mv config.sample.inc.phpconfig.inc.php
(3)编辑config.inc.php文件,用openssl生成的随机码填充blowfish_secret字段。
(4)编辑config.inc.php文件,修改[‘Servers‘][$i][‘host‘]字段的IP地址为172.16.254.35。
(5)在浏览器里打开www2.magedu.com测试。
在三台主机上分别安装httpd、php-fpm、MariaDB
原文地址:http://tiankongzhiling.blog.51cto.com/11639803/1828260