CentOS 7, lamp(module);
实现:
(1) 三者分离于两台主机;
(2) 一个虚拟主机用于提供phpMyAdmin;另一个虚拟主机用于提供wordpress;
(3) 为php提供xcache;
(4) 为phpMyAdmin网站提供https虚拟主机
ON http(172.16.17.7):
1)安装httpd及php程序包
[root@node1 ~]# yum -y install httpd php php-mysql php-mbstring
2)httpd虚拟主机www.pma.com以及www.wordpress.com,新建/etc/httpd/conf.d/vhosts.conf
<VirtualHost *:80> ServerName www.pma.com DocumentRoot "/web/pma/htdocs" <Directory "/web/pma/htdocs"> Options None AllowOverride None Require all granted </Directory> </VirtualHost> <VirtualHost *:80> ServerName www.wordpress.com DocumentRoot "/web/wordpress/htdocs" <Directory "/web/wordpress/htdocs"> Options None AllowOverride None Require all granted </Directory> </VirtualHost>
3)安装配置PHPmyadmin程序
[root@node1 ~]# mkdir -pv /web/{pma,wordpress} [root@node1 ~]# unzip phpMyAdmin-4.4.14.1-all-languages.zip -d /web/pma/ [root@node1 ~]# mv /web/pma/phpMyAdmin-4.4.14.1-all-languages/ /web/pma/htdocs [root@node1 ~]# cd /web/pma/htdocs [root@node1 htdocs]# cp config.sample.inc.php config.inc.php [root@node1 htdocs]# openssl rand -base64 20 5Cfn69rDk+6I3Twd4KtgLfT/v5k= 编辑config.inc.php文件,将生成的随机数复制到里面,然后更改数据库连接主机: $cfg['blowfish_secret'] = '5Cfn69rDk+6I3Twd4KtgLfT/v5k'; $cfg['Servers'][$i]['host'] = '172.16.17.8';
4)安装配置wordpress程序
[root@node1 ~]# unzip wordpress-4.3.1-zh_CN.zip -d /web/wordpress/ [root@node1 ~]# mv /web/wordpress/wordpress/ /web/wordpress/htdocs [root@node1 ~]# cd /web/wordpress/htdocs [root@node1 htdocs]# cp wp-config-sample.php wp-config.php 编辑wp-config.php文件,配置数据库连接信息: define('DB_NAME', 'wpdb'); define('DB_USER', 'wpuser'); define('DB_PASSWORD', 'wppasswd'); define('DB_HOST', '172.16.17.8');
5)启动httpd服务
[root@node1 ~]# httpd -t Syntax OK [root@node1 ~]# systemctl start httpd.service
ON mariadb(172.16.17.8):
1)创建运行mariadb的用户
[root@node2 ~]# groupadd -r mysql [root@node2 ~]# useradd -r -g mysql mysql
2)创建数据库存放目录
[root@node2 ~]# mkdir -pv /data/mysql [root@node2 ~]# chown -R mysql.mysql /data/mysql/
3)解压mariadb程序包至/usr/local,并创建mysql软链接
[root@node2 ~]# tar xf mariadb-5.5.46-linux-x86_64.tar.gz -C /usr/local/ [root@node2 ~]# cd /usr/local/ [root@node2 local]# ln -sv mariadb-5.5.46-linux-x86_64/ mysql
4)初始化数据库
[root@node2 local]# chown -R root.mysql mysql/ [root@node2 mysql]# scripts/mysql_install_db --user=mysql --datadir=/data/mysql
5)提供mysql主配置文件并编辑之
[root@node2 mysql]# mkdir /etc/mysql [root@node2 mysql]# cp support-files/my-medium.cnf /etc/mysql/my.cnf 在my.cnf配置文件中的[mysqld]端添加以下内容: datadir = /data/mysql //设置mysql的数据存储目录 innodb_file_per_table = ON //设置innodb存储引擎独立存储数据库 skip_name_resolve = ON //禁止mysql进行反解主机名
6)提供mysql服务脚本
[root@node2 mysql]# cp support-files/mysql.server /etc/rc.d/init.d/mysqld [root@node2 mysql]# chmod +x /etc/rc.d/init.d/mysqld [root@node2 mysql]# chkconfig --add mysqld [root@node2 mysql]# chkconfig mysqld on
7)启动mysqld服务
[root@node2 ~]# service mysqld start
8)创建wpdb库,授权wpuser用户连接
MariaDB [(none)]> CREATE SCHEMA wpdb; MariaDB [(none)]> GRANT ALL PRIVILEGES ON wpdb.* TO 'wpuser'@'172.16.%.%' IDENTIFIED BY 'wppasswd'; MariaDB [(none)]> GRANT ALL PRIVILEGES ON *.* TO 'root'@'172.16.%.%' IDENTIFIED BY '123qwe!@#'; MariaDB [(none)]> FLUSH PRIVILEGES;
打开浏览器,添加hosts文件解析,访问网站: