王科 2019-06-04
一、安装环境 LAMP
1、安装apache
yum install -y httpd httpd服务开机进行自启:systemctl enable httpd 启动httpd服务:systemctl start httpd 开启80端口:iptables -I INPUT -p tcp -m state --state NEW -m tcp --dport 80 -j ACCEPT 查看端口号:iptables -L -n
有些CentOS 7.6里面没有安装wget命令,所以要自己安装:
yum -y install wget
下载mysql的repo源:
wget http://repo.mysql.com/mysql-community-release-el7-5.noarch.rpm
安装mysql-community-release-el7-5.noarch.rpm包
rpm -ivh mysql-community-release-el7-5.noarch.rpm
安装MYSQL
sudo yum install -y mysql-server
重启服务:
systemctl restart mysql 或 systemctl restart mysql.service
登录,并修改密码:
mysql -u root mysql > use mysql; mysql > update user set password=password(‘123456‘) where user=‘root‘; mysql > flush privileges; mysql > exit;
安装php环境
yum -y install php
rpm -ql php
yum install -y php php-mysql
rpm -ql php-mysql
yum install -y php-gd php-ldap php-odbc php-pear php-xml php-xmlrpc php-mbstring php-snmp php-soap curl curl-devel php-bcmath
放入测试文件:
cd /var/www/html echo '<?php phpinfo();?>' >index.php
systemctl restart httpd
安装Zabbix存储库
rpm -i https://repo.zabbix.com/zabbix/4.0/rhel/7/x86_64/zabbix-release-4.0-1.el7.noarch.rpm
yum install zabbix-server-mysql zabbix-web-mysql zabbix-agent
# mysql -uroot -p password mysql> create database zabbix character set utf8 collate utf8_bin; mysql> grant all privileges on zabbix.* to 'zabbix'@'%' identified by 'zabbix'; mysql> source create.sql; mysql> quit;
vim /etc/zabbix/zabbix_server.conf
编辑文件/etc/httpd/conf.d/zabbix.conf,取消注释并为您设置正确的时区。
vim /etc/httpd/conf.d/zabbix.conf 在:# php_value date.timezone Europe/Riga
加:php_value date.timezone Asia/Shanghai
正常安装完zabbix后,登录后zabbix监控报错zabbix server is not running: the information displayed may not be current
下面的几种情况都有可能引起这个错误,
1. selinux是否关闭。一定要关闭这个,开启selinux会引起一连串问题,甚至zabbix的discovery功能也不能正常使用
临时关闭:setenforce 0
永久关闭:vi /etc/selinux/config
关闭防火墙
临时关闭:systemctl stop firewalld.service 永久关闭:systemctl disable firewalld.service
rpm -i https://repo.zabbix.com/zabbix/4.0/rhel/7/x86_64/zabbix-release-4.0-1.el7.noarch.rpm
安装方法和安装zabbix一样
yum install zabbix-agent zabbix-sender -y
vim /etc/zabbix/zabbix_agentd.conf
vim /etc/zabbix/zabbix_agentd.conf PidFile=/var/run/zabbix/zabbix_agentd.pid LogFile=/var/log/zabbix/zabbix_agentd.log LogFileSize=0 Server=192.168.2.76 监控服务器是哪台主机 ListenIP=0.0.0.0 StartAgents=3 ServerActive=127.0.0.1 被监控的服务器是哪台主机 Hostname=node1 被监控主机名 启动agent服务 systemctl start zabbix-agent
接着在zabbix web界面手动将该主机纳入监控的主机上
记得被监控的主机关闭:selinux。
<?php. if (!empty($_POST)) {. $data1 = $_POST["data1"];$data2 = $_POST["data2"];$fuhao = $_POST["fuh