转载自 http://blog.csdn.net/asionliang/article/details/51733833
最简单有效的办法!
从网上看过N篇教程,小白编译各种出错,无奈选择LNMP一键安装包,解决所有问题。感谢lnmp.org的lamp一体包,现已成功安装,做个笔记,以便后查。
1、配置防火墙
[root~]#firewall-cmd --permanent --zone=public --add-service=http #开启http端口
[root~]#firewall-cmd --reload #刷新策略
2、禁用selinux
[root~]#vi /etc/selinux/config
#SELINUX=enforcing #注释掉
#SELINUXTYPE=targeted #注释掉
SELINUX=disabled #增加
[root~]#setenforce 0 #配置立即生效
3、安装LNMP
[root~]#yum install screen #安装screen(中断可运行 screen -r 重连)
[root~]#screen -S lnmp #建立一个lnmp作业
[root~]#wget -c http://soft.vpser.NET/lnmp/lnmp1.3-full.tar.gz && tar zxf lnmp1.3-full.tar.gz && cd lnmp1.3-full && ./install.sh lnmp
#下载、压解并安装LNMP
Please setup root password of MySQL.(default password:root) #设置MysqL密码
Do you want to enable or disable the InnoDB storage Engine? #是否启用InnoDB引擎
You have 5 options for your database install. #选择安装数据库版本
You have 6 options for your PHP install. #选择安装PHP版本(zabbix3.0需5.4以上)
You have 3 options for your Memory Allocator install. #选择内存优化(默认:无)
完成安装后显示:Nginex:OK,MysqL:OK,PHP:OK
4、安装及配置zabbix
[root~]#[root~]#um install MysqL-devel net-snmp-devel curl curl-devel -y #安装zabbix相关的环境
[root~]#mkdir -p /home/soft
[root~]#wget -c http://ncu.dl.sourceforge.Net/project/zabbix/ZABBIX%20Latest%20Development/3.0.0alpha2/zabbix-3.0.0alpha2.tar.gz
#下载zabbix3.0 (参数:-c 中断重连)
[root~]#tar zxvf zabbix-3.0.0alpha2.tar.gz
[root~]#groupadd zabbix #建用户组
[root~]#useradd -g zabbix zabbix #建用户
[root~]#ln -s /usr/local/lib/libiconv.so.2 /usr/lib/libiconv.so.2 #添加软连接
[root~]#/sbin/ldconfig #立即生效
[root~]#cd zabbix-3.0.0alpha2
[root~]#./configure --prefix=/usr/local/zabbix --enable-server --enable-agent --with-MysqL --enable-ipv6 --with-net-snmp --with-libcurl --with-libxml2
#编译
[root~]#make && make install
[root~]#ln -s /usr/local/zabbix/sbin/* /usr/local/sbin/ #添加系统软连接
[root~]#ln -s /usr/local/zabbix/bin/* /usr/local/bin/ #添加系统软连接
[root~]#vi /etc/services #添加zabbix服务对应的端口
zabbix-agent 10050/tcp # Zabbix Agent |
zabbix-agent 10050/udp # Zabbix Agent |
zabbix-trapper 10051/tcp # Zabbix Trapper |
zabbix-trapper 10051/udp # Zabbix Trapper |
[root~]#vi /usr/local/zabbix/etc/zabbix_server.conf #修改zabbix配置文件,配置zabbix_server
DBName=zabbix |
DBUser=zabbix |
DBPassword=123456 |
ListenIP=localhost |
AlertScriptsPath=/usr/local/zabbix/share/zabbix/alertscripts |
#Alertscriptspath : zabbix运行脚本存放目录
[root~]#cp /home/soft/zabbix-3.0.0alpha2/misc/init.d/fedora/core/zabbix_server /etc/rc.d/init.d/zabbix_server
#添加开机服务器端启动脚本
[root~]#cp /home/soft/zabbix-3.0.0alpha2/misc/init.d/fedora/core/zabbix_agentd /etc/rc.d/init.d/zabbix_agentd
#添加开机客户端启动脚本
[root~]#chmod +x /etc/rc.d/init.d/zabbix_server #添加脚本执行权限 +x
[root~]#chmod +x /etc/rc.d/init.d/zabbix_agentd #添加脚本执行权限 +x
[root~]#chkconfig zabbix_server on #添加开机启动
[root~]#chkconfig zabbix_agentd on #添加开机启动
[root~]#cp /home/soft/zabbix-3.0.0alpha2/misc/init.d/fedora/core/zabbix_server /etc/init.d/zabbix_server
#添加开机服务器端启动脚本
[root~]#cp /home/soft/zabbix-3.0.0alpha2/misc/init.d/fedora/core/zabbix_agentd /etc/init.d/zabbix_agentd
#添加开机客户端启动脚本
[root~]#chmod +x /etc/init.d/zabbix_server #添加脚本执行权限 +x
[root~]#chmod +x /etc/init.d/zabbix_agentd #添加脚本执行权限 +x
[root~]#vi /etc/rc.d/init.d/zabbix_server #编辑服务端配置文件 :设置zabbix安装目录
BASEDIR=/usr/local/zabbix/ |
vi /etc/rc.d/init.d/zabbix_agentd #编辑客户端配置文件 :设置zabbix安装目录
BASEDIR=/usr/local/zabbix/ |
[root~]#etc/init.d/下的做同样修改 #同上
5、配置MysqL
[root~]#cd /home/soft/zabbix-3.0.0alpha2/database/MysqL
[root~]#MysqL -u root -p
MysqL> | create database zabbix character set utf8; |
GRANT USAGE ON *.* TO 'user01'@'localhost' IDENTIFIED BY '123456' WITH GRANT OPTION; | |
flush privileges; | |
grant all on zabbix.* to 'zabbix'@'localhost' identified by '123456' with grant option; | |
flush privileges; | |
use zabbix | |
source /home/soft/zabbix-3.0.0alpha2/database/MysqL/schema.sql | |
source /home/soft/zabbix-3.0.0alpha2/database/MysqL/images.sql | |
source /home/soft/zabbix-3.0.0alpha2/database/MysqL/data.sql |
#1、建立zabbxi库,编码为UTF8;2、 创建MysqL用户密码;3、刷新;4、允许账户zabbix能从本机连接到数据库zabbix;5678、安顺序导入数据库
6、配置WEB站点
[root~]#cd /home/soft/zabbix-3.0.0alpha2/frontends
[root~]#cp -rf PHP /home/www/zabbix
[root~]#chown -R www.www /home/www/zabbix
7、域名设置等
[root~]#lnmp vhost add
Please enter domain |
do you want to add more domain name? N |
please enter the directory for the domain:/home/www/zabbix/ |
allow rewrite rule? N |
allow access_log? Y |
create database and MysqL user with same name: N |
create ftp account: N |
完成后会显示相关信息 |
8、其它设置
[root~]#vi /usr/local/zabbix/etc/zabbix_server.conf #解决 zabbix_server 不能监听端口tcp 10051
DBSocket=/tmp/MysqL.sock |
9、 重启 Nginx
[root~]#Nginx -s reload
DONE!!