liunx 下使用安装lnmp 到zabbix编译安装

来源:互联网 发布:如何打开防火墙端口 编辑:程序博客网 时间:2024/06/14 23:04

1、禁用selinux
    [root@localhost~]# vi /etc/selinux/config
          #SELINUX=enforcing               #注释掉
          #SELINUXTYPE=targeted        #注释掉                                                       
          SELINUX=disabled                   #增加
    [root@localhost~]# setenforce 0                        #配置立即生效


2、安装LNMP(https://lnmp.org/install.html)
      [root@localhost~]# yum install screen         #安装screen(中断可运行 screen -r 重连)
      [root@localhost~]#screen -S lnmp              #建立一个lnmp作业
      [root@localhost~]#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


3、安装及配置zabbix
      [root@localhost~]##yum install mysql-devel net-snmp-devel curl curl-devel -y     #安装zabbix相关的环境
      [root@localhost~]#mkdir -p /home/soft
      [root@localhost~]#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@localhost~]#tar zxvf zabbix-3.0.0alpha2.tar.gz
      [root@localhost~]#groupadd zabbix         #建用户组
      [root@localhost~]#useradd -g zabbix zabbix       #建用户
      [root@localhost~]#ln -s /usr/local/lib/libiconv.so.2  /usr/lib/libiconv.so.2              #添加软连接
      [root@localhost~]#/sbin/ldconfig                  #立即生效
      [root@localhost~]#cd zabbix-3.0.0alpha2
      [root@localhost~]#./configure --prefix=/usr/local/zabbix --enable-server --enable-agent --with-mysql --enable-ipv6 --with-net-snmp --with-libcurl --with-libxml2    #编译
      [root@localhost~]#make && make install
      [root@localhost~]#ln -s /usr/local/zabbix/sbin/* /usr/local/sbin/       #添加系统软连接
      [root@localhost~]#ln -s /usr/local/zabbix/bin/* /usr/local/bin/         #添加系统软连接
      [root@localhost~]#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@localhost~]#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@localhost~]#cp /home/soft/zabbix-3.0.0alpha2/misc/init.d/fedora/core/zabbix_server /etc/rc.d/init.d/zabbix_server
                               #添加开机服务器端启动脚本
      [root@localhost~]#cp /home/soft/zabbix-3.0.0alpha2/misc/init.d/fedora/core/zabbix_agentd /etc/rc.d/init.d/zabbix_agentd
                               #添加开机客户端启动脚本
      [root@localhost~]#chmod +x /etc/rc.d/init.d/zabbix_server                                                #添加脚本执行权限 +x
      [root@localhost~]#chmod +x /etc/rc.d/init.d/zabbix_agentd                                              #添加脚本执行权限 +x
      [root@localhost~]#chkconfig zabbix_server on                                                                   #添加开机启动
      [root@localhost~]#chkconfig zabbix_agentd on                                                                  #添加开机启动
      [root@localhost~]#cp /home/soft/zabbix-3.0.0alpha2/misc/init.d/fedora/core/zabbix_server /etc/init.d/zabbix_server
                                    #添加开机服务器端启动脚本
      [root@localhost~]#cp /home/soft/zabbix-3.0.0alpha2/misc/init.d/fedora/core/zabbix_agentd /etc/init.d/zabbix_agentd 
                                   #添加开机客户端启动脚本
      [root@localhost~]#chmod +x /etc/init.d/zabbix_server       #添加脚本执行权限 +x
      [root@localhost~]#chmod +x /etc/init.d/zabbix_agentd       #添加脚本执行权限 +x
      [root@localhost~]#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@localhost~]#etc/init.d/下的做同样修改                #同上


5、配置MYSQL
      [root@localhost~]#cd /home/soft/zabbix-3.0.0alpha2/database/mysql
      [root@localhost~]#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@localhost~]#cd /home/soft/zabbix-3.0.0alpha2/frontends 
      [root@localhost~]#cp -rf php /home/www/zabbix 
      [root@localhost~]#chown -R www.www /home/www/zabbix


7、域名设置等
      [root@localhost~]#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@localhost~]#vi /usr/local/zabbix/etc/zabbix_server.conf     #解决 zabbix_server  不能监听端口tcp  10051
DBSocket=/tmp/mysql.sock


9、 重启 nginx 
      [root@localhost~]#nginx -s reload


查看服务
      [root@localhost~]ps aux|grep zabbix 
查看端口  
      [root@localhost~]netstat -anplut|grep 10051

      [root@localhost~]netstat -anplut|grep 10051

如果有问题去到/tmp 下去找日志

原创粉丝点击