一、环境配置:
关闭防火墙和设置SELinux:
使用httpd+FastCGI的方式实现整合:
1.php-5.3.3+版本中才能默认实现;
2.httpd支持proxy_fcgi_module,默认httpd-2.2中不支持此模块,httpd-2.4支持;
需要安装的模块:php-fpm //php-fpm和php不能同时存在,要安装php-fpm需要首先卸载php
安装应用程序:
[root@chenliang ~]# yum install -y php-fpm php-gd php-mbstring php-mysql mod_ssl mariadb-server
开启服务:
[root@chenliang ~]# systemctl start httpd.service
[root@chenliang ~]# systemctl start mariadb.service
查看服务启动状态:
httpd, php, mariadb分别部署在一个单独的主机上(httpd, php, mariadb三个应用程序直接安装在主机上就可以)
一个虚拟主机提供phpMyAdmin,另一个虚拟主机提供wordpress(需要配置额外的两个基于FQDN的虚拟主机地址):
配置虚拟主机:
[root@chenliang ~]# cd /etc/httpd/conf.d
[root@chenliang conf.d]# ls
autoindex.conf README ssl.conf userdir.conf welcome.conf
[root@chenliang conf.d]# vim vhost1.conf
<VirtualHost 172.16.72.1:80>
ServerName www.clvhost1.com
DocumentRoot "/var/www/html/vhost1"
ProxyRequests off
ProxyPassMatch ^/(..php)$ fcgi://172.16.72.1:9000/var/www/html/vhost1$1
<Directory "/var/www/html/vhost1">
Options None
AllowOverride None
Require all granted
</Directory>
</VirtualHost>
[root@chenliang conf.d]# vim vhost1.conf
<VirtualHost 172.16.72.1:80>
ServerName www.clvhost1.com
DocumentRoot "/var/www/html/vhost1"
ProxyRequests off
ProxyPassMatch ^/(..php)$ fcgi://172.16.72.1:9000/var/www/html/vhost1/$1
<Directory "/var/www/html/vhost1">
Options None
AllowOverride None
Require all granted
</Directory>
</VirtualHost>
创建目录和主页文件:
[root@chenliang conf.d]# mkdir -pv /var/www/html/vhost{1,2}
mkdir: 已创建目录 "/var/www/html/vhost1"
mkdir: 已创建目录 "/var/www/html/vhost2"
[root@chenliang conf.d]# echo "Vhost1‘s testpage." >>
autoindex.conf ssl.conf vhost1.conf welcome.conf
README userdir.conf vhost2.conf
[root@chenliang conf.d]# echo "Vhost1‘s testpage." >> /var/www/html/vhost1/index.html
[root@chenliang conf.d]# echo "Vhost2‘s testpage." >> /var/www/html/vhost2/index.html
查看语法没有问题(httpd -t)后重启httpd服务(systemctl restart httpd.service),在客户端本地主机添加解析条目:
C盘下\Windows\System32\drivers\etc\hosts文件添加:172.16.72.1 www.clvhost1.com www.clvhost2.com
测试静态页面结果:
[root@chenliang conf.d]# cd /etc/php-fpm.d/www.conf
listen = 172.16.72.1:9000
listen.allowed_clients = 172.16.72.1
创建数据库并授权用户,用于测试数据库连接:
测试数据库连接状态:
CentOS 7中基于rpm包方式安装部署apm(php-fpm) + xcache
原文地址:http://blog.51cto.com/chenliangdeeper/2114846