第17周

1、部署分离的LAMP,部署到二台服务器上,php加载xcache模块

01主机安装php和httpd,02主机安装mysql(mariadb)

[root@centos01 ~]#yum install php php-mysql httpd -y
[root@centos02 ~]#yum install mariadb-server.x86_64 -y
上传wordpress压缩包到01主机

配置并启动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主机验证mysql远程连接
[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数据库的名称 */
define('DB_NAME', 'wordpress');

/** MySQL数据库用户名 */
define('DB_USER', 'wordpress');

/** MySQL数据库密码 */
define('DB_PASSWORD', '110110');

/** MySQL主机 */
define('DB_HOST', '192.168.7.72'); 
[root@centos01 ~]#systemctl start httpd.service
D4qWV.png

D41cA.png

D4uMY.png

2、收集apache访问日志,并实现图形化展示

注:rsyslog与php也装在01机器上
mysql服务器上授权rsyslog能连接此数据库

[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服务器上安装mysql模块相关的程序包

[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上创建数据库和表

[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

你可能感兴趣的:(第17周)