1、部署分離的LAMP,部署到二臺(tái)服務(wù)器上,php加載xcache模塊
01主機(jī)安裝php和httpd,02主機(jī)安裝mysql(mariadb)
[root@centos01 ~]#yum install php php-mysql httpd -y
[root@centos02 ~]#yum install mariadb-server.x86_64 -y
上傳wordpress壓縮包到01主機(jī)
配置并啟動(dòng)mysql
[root@centos02 ~]#systemctl start mariadb.service
[root@centos02 ~]#mysql
Welcome to the MariaDB monitor. Commands end with ; or \g.
Your MariaDB connection id is 2
Server version: 5.5.65-MariaDB MariaDB Server
Copyright (c) 2000, 2018, Oracle, MariaDB Corporation Ab and others.
Type 'help;' or '\h' for help. Type '\c' to clear the current input statement.
MariaDB [(none)]> create database wordpress;
Query OK, 1 row affected (0.00 sec)
MariaDB [(none)]> grant all on wordpress.* to wordpress@'192.168.7.%' identified by '110110';
Query OK, 0 rows affected (0.00 sec)
#01主機(jī)驗(yàn)證mysql遠(yuǎn)程連接
[root@centos01 ~]#mysql -uwordpress -p110110 -h192.168.7.72
Welcome to the MariaDB monitor. Commands end with ; or \g.
Your MariaDB connection id is 3
Server version: 5.5.65-MariaDB MariaDB Server
Copyright (c) 2000, 2018, Oracle, MariaDB Corporation Ab and others.
Type 'help;' or '\h' for help. Type '\c' to clear the current input statement.
MariaDB [(none)]> use database wordpress;
ERROR 1044 (42000): Access denied for user 'wordpress'@'192.168.7.%' to database 'database'
MariaDB [(none)]> use wordpress;
Database changed
MariaDB [wordpress]> show tables;
Empty set (0.00 sec)
安裝配置wordpress
[root@centos01 ~]#mkdir /data/wordpress
[root@centos01 ~]#tar xvf wordpress-5.0.2-zh_CN.tar.gz -C /data/wordpress
[root@centos01 ~]#cd /data/
[root@centos01 data]#setfacl -Rm u:apache:rwx wordpress
[root@centos01 data]#mv wordpress/* /var/www/html/
[root@centos01 wordpress]#mv wp-config-simple.php wp-config.php
[root@centos01 wordpress]#vim wp-config.php #修改配置文件
/** WordPress數(shù)據(jù)庫(kù)的名稱 */
define('DB_NAME', 'wordpress');
/** MySQL數(shù)據(jù)庫(kù)用戶名 */
define('DB_USER', 'wordpress');
/** MySQL數(shù)據(jù)庫(kù)密碼 */
define('DB_PASSWORD', '110110');
/** MySQL主機(jī) */
define('DB_HOST', '192.168.7.72');
[root@centos01 ~]#systemctl start httpd.service

D4qWV.png

D41cA.png

D4uMY.png
2、收集apache訪問日志,并實(shí)現(xiàn)圖形化展示
注:rsyslog與php也裝在01機(jī)器上
mysql服務(wù)器上授權(quán)rsyslog能連接此數(shù)據(jù)庫(kù)
[root@centos02 ~]#mysql
Welcome to the MariaDB monitor. Commands end with ; or \g.
Your MariaDB connection id is 4
Server version: 5.5.65-MariaDB MariaDB Server
Copyright (c) 2000, 2018, Oracle, MariaDB Corporation Ab and others.
Type 'help;' or '\h' for help. Type '\c' to clear the current input statement.
MariaDB [(none)]> grant all on Syslog.* to loguser@'192.168.7.%' identified by '120120';
Query OK, 0 rows affected (0.00 sec)
rsyslog服務(wù)器上安裝mysql模塊相關(guān)的程序包
[root@centos01 ~]#yum install rsyslog-mysql.x86_64 -y
[root@centos01 ~]#rpm -ql rsyslog-mysql
/usr/lib64/rsyslog/ommysql.so
/usr/share/doc/rsyslog-8.24.0/mysql-createDB.sql
rsyslog上創(chuàng)建數(shù)據(jù)庫(kù)和表
[root@centos01 ~]#mysql -uloguser -p120120 -h192.168.7.72 < /usr/share/doc/rsyslog-8.24.0/mysql-createDB.sql
[root@centos01 ~]#mysql -uloguser -p120120 -h192.168.7.72
Welcome to the MariaDB monitor. Commands end with ; or \g.
Your MariaDB connection id is 7
Server version: 5.5.65-MariaDB MariaDB Server
Copyright (c) 2000, 2018, Oracle, MariaDB Corporation Ab and others.
Type 'help;' or '\h' for help. Type '\c' to clear the current input statement.
MariaDB [(none)]> show databases;
+--------------------+
| Database |
+--------------------+
| information_schema |
| Syslog |
| test |
+--------------------+
3 rows in set (0.00 sec)
MariaDB [(none)]> use Syslog
Reading table information for completion of table and column names
You can turn off this feature to get a quicker startup with -A
Database changed
MariaDB [Syslog]> show tables;
+------------------------+
| Tables_in_Syslog |
+------------------------+
| SystemEvents |
| SystemEventsProperties |
+------------------------+
2 rows in set (0.00 sec)
修改rsyslog配置文件
[root@centos01 ~]#vim /etc/rsyslog.conf
#### MODULES ####
$ModLoad ommysql
#### RULES ####
*.info;mail.none;authpriv.none;cron.none :ommysql:192.168.7.72,Syslog,loguser,120120
安裝loganalyzer
[root@centos01 ~]#yum install php-gd -y #圖形化顯示插件
[root@centos01 ~]#tar xvf loganalyzer-4.1.7.tar.gz
[root@centos01 ~]#cp -a loganalyzer-4.1.7/src/ /var/www/html/loganalyzer
[root@centos01 ~]#cd /var/www/html/loganalyzer
[root@centos01 loganalyzer]#touch config.php
[root@centos01 loganalyzer]#chmod 666 config.php
[root@centos01 loganalyzer]#systemctl restart rsyslog.service
[root@centos01 loganalyzer]#systemctl restart httpd.service
安裝過程圖

3IahG.png

3IZpK.png

3IW8I.png

3IHPa.png

3IK1R.png

3IvaT.png