该文件基于Centos7.2(最小化系统)实践进行的总结
vi /etc/profile
HISTFILESIZE=10000 >/dev/null 2>&1 ##最大存10000条记录命令,并把超过的删除
HISTSIZE=10000>/dev/null 2>&1 ##大小10000
export HISTTIMEFORMAT="%F %T `whoami` " >/dev/null 2>&1 ##赋值给命令
alias vi=vim ##别名
source /etc/profile 生效配置文件信息
1、安装基础下载工具
yum -y install vim wget
2、##配置aliyun的yum源
cd /etc/yum.repos.d/
mkdir backup
mv *.repo ./backup
wget -O ./CentOS-Base.repo http://mirrors.aliyun.com/repo/Centos-7.repo
yum clean all
yum makecache
yum -y update
3、安装EPEL源(主要用于第三方软件yum安装):
rpm -ivh http://dl.fedoraproject.org/pub/epel/7/x86_64/e/epel-release-7-9.noarch.rpm (centos 7系列)
rpm --import /etc/pki/rpm-gpg/RPM-GPG-KEY-EPEL-7
rpm -ivh http://dl.fedoraproject.org/pub/epel/6/x86_64/epel-release-6-8.noarch.rpm (centos 6系列)
rpm --import /etc/pki/rpm-gpg/RPM-GPG-KEY-EPEL-6
验证查看是否安装成功:
yum repolist
4、关闭Centos7默认防火墙、SELinux
firewall-cmd --state
systemctl stop firewalld.service
systemctl disable firewalld.service
sed -i "s/SELINUX=enforcing/SELINUX=disabled/g" '/etc/selinux/config'
setenforce 0
5、安装MySQL并进行配置
rpm -ivhhttp://repo.mysql.com/mysql-community-release-el7-5.noarch.rpm
yum install -y mysql-server
mkdir -p /data/mysql
chown -R mysql:mysql /data/mysql
mv /etc/my.cnf /etc/my.cnf.bak
修改MySQL的root用户的密码以及打开远程连接
mysql -uroot -p
mysql> use mysql;
mysql> desc user;
mysql> update user set Password = password('techview!@#$') where User='root'; //设置root用户密码
mysql> select Host,User,Password from user where User='root';
mysql> flush privileges;
mysql> exit
创建数据库:
mysql> CREATE DATABASE zabbixdb DEFAULT CHARACTER SET utf8 COLLATE utf8_general_ci;
授连接次数据库的权限:
mysql> grant all privileges on zabbixdb.* to zabbix@'%' identified by '密码';
mysql> flush privileges;
6、搭建LNMP环境
yum install nginx php php-mysql php-fpm -y
cat > /etc/nginx/conf.d/zabbix.conf << \EOF
server {
root /var/www/zabbix;
index index.php index.html;
access_log /var/log/nginx/access_zabbix.log;
error_log /var/log/nginx/error_zabbix.log;
location /nginx_status { ##nginx状态(监控)
stub_status on;
access_log off;
allow 127.0.0.1;
deny all;
}
location ~ ^/(php-fpm_status)$ {
include fastcgi_params;
fastcgi_pass 127.0.0.1:9000;
fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name;
}
location ~ \.php$ {
fastcgi_pass 127.0.0.1:9000;
fastcgi_index index.php;
fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name;
include fastcgi_params;
fastcgi_buffer_size 128k;
fastcgi_buffers 4 256k;
fastcgi_busy_buffers_size 256k;
}
}
EOF
sed -i '38,57s/^/#/' /etc/nginx/nginx.conf ##把38行到57的注释掉
sed -i 's/^;date.timezone =/date.timezone = Asia\/Shanghai/' /etc/php.ini #Shanghai##时区
sed -i 's/^post_max_size =.*/post_max_size = 16M/' /etc/php.ini ##post写 GTA读
sed -i 's/^max_execution_time =.*/max_execution_time = 300/' /etc/php.ini #调整为服务超过300 就超时
sed -i 's/^max_input_time =.*/max_input_time = 300/' /etc/php.ini #input为流入时间
sed -i 's/^user = .*/user = nginx/' /etc/php-fpm.d/www.conf #php 用户
sed -i 's/^group = .*/group = nginx/' /etc/php-fpm.d/www.conf #php 用户组
chown nginx: /var/log/php-fpm
7、Zabbix应用部署
rpm -ivh http://repo.zabbix.com/zabbix/3.2/rhel/7/x86_64/zabbix-release-3.2-1.el7.noarch.rpm
备注:此处可以执行修改Zabbix的版本源
(见https://www.zabbix.com/documentation/3.2/manual/installation/install_from_packages/repository_installation)
rpm --import /etc/pki/rpm-gpg/RPM-GPG-KEY-CentOS-7 ##--import 添加一个yum源
yum install -y zabbix-server-mysql zabbix-web-mysql zabbix-get zabbix-agent
# 导入Zabbix服务端的表结构
cd /usr/share/doc/zabbix-server-mysql-3.2.3/
zcat create.sql.gz |mysql -uroot -p zabbixdb#库名# #插入数据库
# 文件权限修改
chown nginx:nginx -R /etc/zabbix/web/
cp -r /usr/share/zabbix /var/www
chown nginx:nginx -R /var/www/zabbix
chown root:nginx /var/lib/php/session
vi /etc/zabbix/zabbix_server.conf
ListenPort=10051
DBHost=IP
DBName=zabbixdb
DBUser=zabbix
DBPassword=密码
DBSocket=/tmp/mysql.sock
DBPort=3306
Timeout=30 #超时30ms
systemctl start mysqld
systemctl start nginx
systemctl start php-fpm
systemctl start zabbix-server
systemctl enable nginx
systemctl enable php-fpm
systemctl enable zabbix-server
8、验证
访问http://localhost/zabbix可查看到页面(默认账号/密码:admin/zabbix)