系统平台:CentOS 7 1611
phpMyAdmin下载地址(CentOS 7 建议不要安装最新版,否则需要编译最新的PHP-fpm)
分别在三台主机上安装httpd(192.168.1.200),PHP-fpm(192.168.1.201),mariadb(192.168.1.202),
1、安装并配置httpd服务器
1.1 安装httpd服务
[root@node1~]#yuminstall-yhttpd
1.2 编辑httpd配置文件并创建虚拟主机
[root@node1~]#mkdir-pv/www/{wp.com,pma.com}/htdocs [root@node1~]#vim/etc/httpd/conf/httpd.conf ServerNamelocalhost:80 #DocumentRoot"/www/wp.com/htdcos" <VirtualHost192.168.1.200:80> ServerNamewww.wp.com DocumentRoot"/www/wp.com/htdocs/" ProxyRequestsoff ProxyPassMatch^/(.*\.PHP)$fcgi://192.168.1.201:9000/www/wp.com/htdocs/$1 <Directory"/www/wp.com/htdocs/"> OptionsNone AllowOverrideNone Requireallgranted </Directory> </VirtualHost> <VirtualHost192.168.1.200:80> ServerNamewww.pma.com DocumentRoot"/www/pma.com/htdocs/" ProxyRequestsoff ProxyPassMatch^/(.*\.PHP)$fcgi://192.168.1.201:9000/www/pma.com/htdocs/$1 <Directory"/www/pma.com/htdocs/"> OptionsFollowSymLinks AllowOverrideNone Requireallgranted </Directory> </VirtualHost>
2、安装并配置PHP-fpm服务
2.1 安装PHP-fpm、PHP-mbstring、PHP-MysqL服务
[root@node2~]#yum-yinstallPHP-fpmPHP-mbstring.x86_64PHP-MysqL
[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
MariaDB[(none)]>createdatabasewp; MariaDB[(none)]>CREATEUESR'wp'@'%.%.%.%'IDENTIFIEDBY'wppasswd'; MariaDB[(none)]>GRANTALLON*.*TOwpuser@'192.168.1.%'IDENTIFIEDBY'wppasswd';
[root@node2wordpress]#unzipwordpress-4.7.4-zh_CN.zip [root@node2wordpress]#unzipPHPMyAdmin-4.0.10.20-all-languages.zip [root@node2html]#ln-svPHPMyAdmin-4.0.10.20-all-languagespma
[root@node2html]#cdwordpress/ [root@node2wordpress]#cpwp-config-sample.PHPwp-config.php [root@node2wordpress]#vimwp-config.php define('DB_NAME','wp');#数据库名称 define('DB_USER','wp');#用于连接数据库的用户名 define('DB_PASSWORD','wppasswd');#用于连接数据库的密码 define('DB_HOST','192.168.1.202');#数据库的路径
[root@node2wordpress]#cd/www/pma.com/htdocs/pma [root@node2pma]#cpconfig.sample.inc.PHPconfig.PHP [root@node2pma]#opensslrand-base6415#生成配置文件中所需的随机数 A42B1Noto1YiqQMC3DV7 [root@node2pma]#vimconfig.PHP $cfg['blowfish_secret']='A42B1Noto1YiqQMC3DV7';/*YOUMUSTFILLINTHISFORCOOKIEAUTH!*/ $cfg['Servers'][$i]['host']='192.168.1.202';
4.4 创建PHP session文件夹并修改权限@H_403_166@
[root@node2pma]#mkdir/var/lib/PHP/session-pv [root@node2pma]#chown-Rapache.apache/var/lib/PHP/session/ [root@node2pma]#systemctlrestartPHP-fpm.service
4.4 复制wordpress和PHPMyAdmin到httpd服务器上对应的路径中
[root@node2pma]#scp-P22/var/www/html/pma/*root@192.168.1.200:/var/www/html/pma [root@node2pma]#scp-P22/var/www/html/wordpress/*root@192.168.1.200:/var/www/html/wordpress
5、为PHP启用加速,安装xcache
[root@node1~]#yum-yinstallPHP-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://www.f2er.com/centos/377584.html