具体请参考http://maoqiu.blog.51cto.com/8570467/1384026 这篇博文


安装phpMyadmin工具

[root@www ~]# mkdir /usr/local/apache2/htdocs/phpmyadm #→创建的根目录

[root@test2 phpmyadm]# tar -xf phpMyAdmin-3.4.11-all-languages.tar.bz2 

[root@www ~]# cp -r phpMyAdmin-3.4.10.1-all-languages/* /usr/local/apache2/htdocs/phpmyadm/

 #→将该工具的所有文件拷贝至文至这个工具的根目录

[root@www htdocs]# cp config.sample.inc.php config.inc.php

[root@test2 phpmyadm]# vi config.inc.php

  a 找到这一行$cfg['Servers'][$i]['host'] = 'localhost';

  并修改为 $cfg['Servers'][$i]['host'] = '172.16.41.2'; #→这是mysql服务器地址

  b 找到这一行 $cfg['blowfish_secret'] = ''; /* YOU MUST FILL IN THIS FOR COOKIE AUTH! */

  并修改为$cfg['blowfish_secret'] = 'ddf5bab147f6cfaef020'; /* YOU MUST FILL IN THIS FOR COOKIE AUTH! */

  注:#这行两个冒号之间我们需要一串cookie码,随机生成一个填在里面,可通过

  [root@www htdocs]# openssl rand -hex 10  #→通过openssl生成一串随机码

  测试我phpMyadmin能否正常工作了

  http://10.10.168.160/phpmyadm/

  2

  搭建wordpress个人博客系统

  a 解压安装wordpress

  [root@test2 wordpress]# tar -xzf wordpress-4.5.3-zh_CN.tar.gz

  [root@test2 wordpress]# cd wordpress

  [root@test2 wordpress]# cp wp-config-sample.php wp-config.php

  [root@test2 wordpress]# mv * /apache1/htdocs/wordpress/

  b 配置虚拟主机

  [root@test2 extra]# vi httpd-vhosts.conf

  <VirtualHost *:80>

    ServerAdmin changhuanyan-ghq@sinosig.com 

    DocumentRoot "/apache1/htdocs/wordpress"  #→这是wordpress博客系统的根目录

    ServerName www.woaixuexi.com  #→这是它的主机名

    ErrorLog "logs/error_log"   #→错误日志

    CustomLog "logs/assess_log" combined  #→访问日志

</VirtualHost>

#保存退出!

c 配置数据库,我们都知道博客系统的账户都是存在后端的数据库中的,故此现需要创建一个博客的数据库

[mysql@test3 ~]$ mysql -uroot -p

Enter password: 

Welcome to the MySQL monitor.  Commands end with ; or \g.

Your MySQL connection id is 14

Server version: 5.6.19-log MySQL Community Server (GPL)


Copyright (c) 2000, 2014, Oracle and/or its affiliates. All rights reserved.


Oracle is a registered trademark of Oracle Corporation and/or its

affiliates. Other names may be trademarks of their respective

owners.


Type 'help;' or '\h' for help. Type '\c' to clear the current input statement.


mysql> CREATE DATABASE worddb; #→这是博客系统的数据库

Query OK, 1 row affected (0.00 sec)

mysql> GRANT ALL PRIVILEGES ON worddb.* TO 'worduser'@'%' IDENTIFIED BY '123456'; #→我授权worduser用户对该数据库具有管理权限,并且它可以在任何远程主机上登陆该数据库操作

Query OK, 0 rows affected (0.00 sec)

mysql> show databases;

+--------------------+

| Database           |

+--------------------+

| information_schema |

| mysql              |

| performance_schema |

| test               |

| worddb             |#→已经创建好了

+--------------------+

5 rows in set (0.00 sec)

mysql> FLUSH PRIVILEGES; #→千万要记得刷新数据库

Query OK, 0 rows affected (0.00 sec)

mysql>

d 修改wordpress配置文件

vi wp-config.php 

/** WordPress数据库的名称 */

define('DB_NAME', 'worddb');


/** MySQL数据库用户名 */

define('DB_USER', 'worduser');


/** MySQL数据库密码 */

define('DB_PASSWORD', '123456');


/** MySQL主机 */

define('DB_HOST', '10.10.168.159');

e 重新加载配置文件

[root@test2 wordpress]# /apache1/bin/httpd -k restart

f 测试,在客户端浏览器中输入http://10.10.168.160/wordpress 即可!

mysql主从设置,通常是编辑hosts来绑定主从ip

修改wordpress配置文件

[root@www ~]# vim /web/blog/wordpress/htdocs/wp-config.php

#修改下面四项即可

define('DB_NAME', 'worddb'); #→WordPress 数据库的名称

define('DB_USER', 'worduser'); #→MySQL 数据库用户名

define('DB_PASSWORD', '123456'); #→MySQL 数据库密码

define('DB_HOST', '10.10.168.159'); #→MySQL 主机

将上一行改为域名

define('DB_HOST', 'www.myworpress.com'); #→MySQL 主机

vi /etc/hosts

10.10.168.159 www.myworpress.com

如果mysql的主库down掉,只需要修改hosts文件里的ip