角色部署:
CentOS 7-2:192.168.18.147(监测端:部署安装zabbix)
CentOS 7-3:192.168.18.128(被监测端)
监测端操作:
[root@cacti ~]# systemctl stop firewalld.service #关闭防火墙功能
[root@cacti ~]# systemctl disable firewalld.service #开机禁用防火墙功能
Removed symlink /etc/systemd/system/multi-user.target.wants/firewalld.service.
Removed symlink /etc/systemd/system/dbus-org.fedoraproject.FirewallD1.service.
[root@cacti ~]# setenforce 0 #关闭增强型安全功能
安装LAMP架构
[root@cacti ~]# yum install -y
httpd
mariadb-server mariadb
php
php-mysql
php-gd
libjpeg*
php-ldap
php-odbc
php-pear
php-xml
php-xmlrpc
php-mhash
编辑apache配置文件
[root@cacti ~]# vim /etc/httpd/conf/httpd.conf
95 ServerName www.yun.com:80 #第95行,删除注释,域名自定义
164 DirectoryIndex index.html index.php #164行,添加首页支持类类型index.php
#修改完成后按Esc退出插入模式,输入:wq保存退出
修改时区为中国
[root@cacti ~]# vim /etc/php.ini
878 date.timezone = PRC #878行,把前面模板的;号删除,后面添加中国时区PRC
#修改完成后按Esc退出插入模式,输入:wq保存退出
[root@cacti ~]# systemctl start httpd.service #启动apache服务
[root@cacti ~]# systemctl start mariadb.service #启动mariadb服务
[root@cacti ~]# netstat -ntap | egrep ‘(3306|80)’ #使用egrep命令同时查看3306和80端口
tcp 0 0 0.0.0.0:3306 0.0.0.0:* LISTEN 4410/mysql
tcp6 0 0 :::80 ::😗 LISTEN 4131/httpd
初始化数据库配置
[root@cacti ~]# mysql_secure_installation
NOTE: RUNNING ALL PARTS OF THIS SCRIPT IS RECOMMENDED FOR ALL MariaDB
SERVERS IN PRODUCTION USE! PLEASE READ EACH STEP CAREFULLY!
In order to log into MariaDB to secure it, we’ll need the current
password for the root user. If you’ve just installed MariaDB, and
you haven’t set the root password yet, the password will be blank,
so you should just press enter here.
Enter current password for root (enter for none): #此处直接回车
OK, successfully used password, moving on…
Setting the root password ensures that nobody can log into the MariaDB
root user without the proper authorisation.
Set root password? [Y/n] y #设置密码
New password: #abc123
Re-enter new password: #确认输入:abc123
Password updated successfully!
Reloading privilege tables…
… Success!
By default, a MariaDB installation has an anonymous user, allowing anyone
to log into MariaDB without having to have a user account created for
them. This is intended only for testing, and to make the installation
go a bit smoother. You should remove them before moving into a
production environment.
Remove anonymous users? [Y/n] n #是否删除匿名用户,选择不删除
… skipping.
Normally, root should only be allowed to connect from ‘localhost’. This
ensures that someone cannot guess at the root password from the network.
Disallow root login remotely? [Y/n] y #是否远程连接
… Success!
By default, MariaDB comes with a database named ‘test’ that anyone can
access. This is also intended only for testing, and should be removed
before moving into a production environment.
Remove test database and access to it? [Y/n] n #是否删除测试数据库
… skipping.
Reloading the privilege tables will ensure that all changes made so far
will take effect immediately.
Reload privilege tables now? [Y/n] y #是否重新加载
… Success!
Cleaning up…
All done! If you’ve completed all of the above steps, your MariaDB
installation should now be secure.
Thanks for using MariaDB!
#验证登录数据库
[root@cacti ~]# mysql -u root -p
Enter password: #输入密码abc123
Welcome to the MariaDB monitor. Commands end with ; or \g.
Your MariaDB connection id is 8
Server version: 5.5.64-MariaDB MariaDB Server
Copyright © 2000, 2018, Oracle, MariaDB Corporation Ab and others.
Type ‘help;’ or ‘\h’ for help. Type ‘\c’ to clear the current input statement.
创建zabbix数据库,并且设置为utf8形式,把里面的字符串转换为二进制
MariaDB [(none)]> CREATE DATABASE zabbix character set utf8 collate utf8_bin;
Query OK, 1 row affected (0.00 sec)
提升用户
MariaDB [(none)]> show databases;
±-------------------+
| Database |
±-------------------+
| information_schema |
| mysql |
| performance_schema |
| test |
| zabbix |
±-------------------+
5 rows in set (0.00 sec)
#此时有zabbix数据库,需要创建管理里这个数据库的用户
MariaDB [(none)]> GRANT all privileges ON . TO ‘zabbix’@’%’ IDENTIFIED BY ‘admin123’;
Query OK, 0 rows affected (0.01 sec)
#把所有数据库和所有表都交给zabbix进行管理,并且设置密码为admin123
MariaDB [(none)]> flush privileges; #刷新
Query OK, 0 rows affected (0.00 sec)
MariaDB [(none)]> quit #退出数据库
Bye
测试php基本信息
[root@localhost ~]# cd /var/www/html/
[root@localhost html]# ls
[root@localhost html]# vim index.php