系统平台:CentOS 7 1611
phpMyAdmin下载地址(CentOS 7 建议不要安装最新版,否则需要编译最新的php-fpm)
分别在三台主机上安装httpd(192.168.1.200),php-fpm(192.168.1.201),mariadb(192.168.1.202),
并提供WordPress、phpMyAdmin应用
1、安装并配置httpd服务器
1.1 安装httpd服务
[root@node1 ~]# yum install -y httpd
1.2 编辑httpd配置文件并创建虚拟主机
[root@node1 ~]# mkdir -pv /www/{wp.com,pma.com}/htdocs [root@node1 ~]# vim /etc/httpd/conf/httpd.conf ServerName localhost:80 #DocumentRoot "/www/wp.com/htdcos" <VirtualHost 192.168.1.200:80> ServerName www.wp.com DocumentRoot "/www/wp.com/htdocs/" ProxyRequests off ProxyPassMatch ^/(.*\.php)$ fcgi://192.168.1.201:9000/www/wp.com/htdocs/$1 <Directory "/www/wp.com/htdocs/"> Options None AllowOverride None Require all granted </Directory> </VirtualHost> <VirtualHost 192.168.1.200:80> ServerName www.pma.com DocumentRoot "/www/pma.com/htdocs/" ProxyRequests off ProxyPassMatch ^/(.*\.php)$ fcgi://192.168.1.201:9000/www/pma.com/htdocs/$1 <Directory "/www/pma.com/htdocs/"> Options FollowSymLinks AllowOverride None Require all granted </Directory> </VirtualHost>
2、安装并配置php-fpm服务
2.1 安装php-fpm、php-mbstring、php-mysql服务
[root@node2 ~]# yum -y install php-fpm php-mbstring.x86_64 php-mysql
2.2 修改php-fpm配置文件
[root@node2 ~]# vim /etc/php-fpm.d/www.conf listen = 0.0.0.0:9000 #表示监听所有端口 ;listen.allowed_clients = 127.0.0.1 #注释掉后,默认允许所有主机访问
2.3 创建/wordpress和phpmyadmin的网页文件目录,并将WordPress和phpmyadmin文件放置在该文件夹中
[root@node2 ~]# mkdir -pv /www/{wp.com,pma.com}/htdocs
3、安装配置mariadb服务
3.1 安装mariadb服务(CentOS 7自带有mariadb服务,启动即可)
[root@node3 ~]# yum -y install mariadb-server
[root@node3 ~]# systemctl start mariadb.service
3.2 创建数据库并添加用户、赋予权限
MariaDB [(none)]> create database wp; MariaDB [(none)]> CREATE UESR 'wp'@'%.%.%.%' IDENTIFIED BY 'wppasswd'; MariaDB [(none)]> GRANT ALL ON *.* TO wpuser@'192.168.1.%' IDENTIFIED BY 'wppasswd';
4、配置WordPress、phpMyAdmin
4.1 解压下载的文件并为phpmyadmin创建链接
[root@node2 wordpress]# unzip wordpress-4.7.4-zh_CN.zip [root@node2 wordpress]# unzip phpMyAdmin-4.0.10.20-all-languages.zip [root@node2 html]# ln -sv phpMyAdmin-4.0.10.20-all-languages pma
4.2 修改WordPress配置文件
[root@node2 html]# cd wordpress/ [root@node2 wordpress]# cp wp-config-sample.php wp-config.php [root@node2 wordpress]# vim wp-config.php define('DB_NAME', 'wp'); #数据库名称 define('DB_USER', 'wp'); #用于连接数据库的用户名 define('DB_PASSWORD', 'wppasswd'); #用于连接数据库的密码 define('DB_HOST', '192.168.1.202'); #数据库的路径
4.3 修改phpMyAdmin的配置文件
[root@node2 wordpress]# cd /www/pma.com/htdocs/pma [root@node2 pma]# cp config.sample.inc.php config.php [root@node2 pma]# openssl rand -base64 15 #生成配置文件中所需的随机数 A42B1Noto1YiqQMC3DV7 [root@node2 pma]# vim config.php $cfg['blowfish_secret'] = 'A42B1Noto1YiqQMC3DV7'; /* YOU MUST FILL IN THIS FOR COOKIE AUTH! */ $cfg['Servers'][$i]['host'] = '192.168.1.202';
4.4 创建php session文件夹并修改权限
[root@node2 pma]# mkdir /var/lib/php/session -pv [root@node2 pma]# chown -R apache.apache /var/lib/php/session/ [root@node2 pma]# systemctl restart php-fpm.service
4.4 复制WordPress和phpMyAdmin到httpd服务器上对应的路径中
[root@node2 pma]# scp -P 22 /var/www/html/pma/* root@192.168.1.200:/var/www/html/pma [root@node2 pma]# scp -P 22 /var/www/html/wordpress/* root@192.168.1.200:/var/www/html/wordpress
5、为PHP启用加速,安装xcache
[root@node1 ~]# yum -y install php-xcache.x86_64 [root@node1 ~]# openssl [root@node1 ~]# openssl OpenSSL> md5 test123(stdin)= cc03e747a6afbbcbf8be7668acfebee5 [root@node1 ~]# vim /etc/php.d/xcache.ini xcache.admin.user = "test" xcache.admin.pass = "cc03e747a6afbbcbf8be7668acfebee5" #此处必须使用MD5加密后的密码
转载于:https://blog.51cto.com/7368072/1925398