本文主要和大家分享LNMP和zabbix設定實例程式碼,希望能幫助大家。
一、zabbix服務端部署
1、解壓縮
tar -xf nginx-1.10.1.tar.gz tar -xf php-5.6.22.tar.gz tar -xf freetype-2.4.0.tar.bz2 tar -xf mysql-5.6.30-linux-glibc2.5-x86_64.tar.gz tar -xf zabbix-3.2.1.tar.gz
2、安裝Nginx
yum -y install gcc openssl-devel pcre-devel useradd -s /sbin/nologin nginx cd ~/nginx-1.10.1/ ./configure \ >--prefix=/usr/local/nginx \ >--user=nginx \ >--group=nginx \ >--with-http_ssl_module make && make install vim /usr/local/nginx/conf/nginx.conf location / { roothtml; indexindex.phpindex.htmlindex.htm; } location ~ \.php$ { root html; fastcgi_pass127.0.0.1:9000; fastcgi_indexindex.php; fastcgi_paramSCRIPT_FILENAME$document_root$fastcgi_script_name; includefastcgi_params; } /usr/local/nginx/sbin/nginx
3、安裝MySQL
useradd mysql mv mysql-5.6.30-linux-glibc2.5-x86_64/ /usr/local/mysql chown -R mysql.mysql /usr/local/mysql/ su - mysql cd /usr/local/mysql/scripts/ ./mysql_install_db \ >--user=mysql \ >--basedir=/usr/local/mysql \ >--datadir=/usr/local/mysql/data exit cd /usr/local/mysql/support-files/ cp my-default.cnf /etc/my.cnf cp mysql.server /etc/init.d/mysql vim /etc/init.d/mysql basedir=/usr/local/mysql datadir=/usr/local/mysql/data echo 'export PATH=/usr/local/mysql/bin:$PATH' >> /etc/profile source /etc/profile chkconfig --add mysql chkconfig mysql on service mysql start /usr/local/mysql/bin/mysqladmin -u root password '123456' mysql -uroot -p123456 mysql> create database zabbix character set utf8; mysql> grant all on zabbix.* to zabbix@localhost identified by 'qwe123';
4、安裝Freetype(可以使用系統自帶的)
cd ~/freetype-2.4.0 ./configure --prefix=/opt/freetype-2.4.0 make && make install yum -y install freetype
5、安裝PHP
yum -y install libjpeg-devel libxml2-devel libpng-devel cd ~/php-5.6.22/ ./configure \ >--prefix=/usr/local/php5/ \ >--enable-fpm \ >--enable-mbstring \ >--enable-bcmath \ >--enable-sockets \ >--with-config-file-path=/usr/local/php5/etc \ >--with-mysql=/usr/local/mysql/ \ >--with-mysqli=/usr/local/mysql/bin/mysql_config \ >--with-gd \ >--with-gettext \ >--with-jpeg-dir \ >--with-freetype-dir=/opt/freetype-2.4.0/ #使用系统自带的不用指安装目录 make && make install cp php.ini-production /usr/local/php5/etc/php.ini vim /usr/local/php5/etc/php.ini date.timezone = Asia/Shanghai max_execution_time = 300 post_max_size = 32M max_input_time = 300 memory_limit = 128M always_populate_raw_post_data = -1 cd /usr/local/php5/etc/ cp php-fpm.conf.default php-fpm.conf vim php-fpm.conf pid = run/php-fpm.pid error_log = log/php-fpm.log log_level = error daemonize = yes user = nginx group = nginx listen = 127.0.0.1:9000 pm = dynamic pm.max_children = 32 pm.start_servers = 15 pm.min_spare_servers = 5 pm.max_spare_servers = 32 cd ~/php-5.6.22/sapi/fpm/ cp init.d.php-fpm /etc/rc.d/init.d/php-fpm chmod +x /etc/rc.d/init.d/php-fpm chkconfig --add php-fpm chkconfig php-fpm on service php-fpm start
6、安裝Zabbix
yum -y install net-snmp-devel curl-devel useradd zabbix cd zabbix-3.2.1 ./configure \ >--prefix=/usr/local/zabbix \ >--enable-server \ >--enable-proxy \ >--enable-agent \ >--with-mysql=/usr/local/mysql/bin/mysql_config \ >--with-net-snmp \ >--with-libcurl make && make install cd ~/zabbix-3.2.1/database/mysql/ mysql -uzabbix -pqwe123 zabbix < schema.sql mysql -uzabbix -pqwe123 zabbix < images.sql mysql -uzabbix -pqwe123 zabbix < data.sql mkdir /var/log/zabbix chown zabbix.zabbix /var/log/zabbix ln -s /usr/local/zabbix/etc/ /etc/zabbix ln -s /usr/local/zabbix/bin/* /usr/bin/ ln -s /usr/local/zabbix/sbin/* /usr/sbin/ ln -s /usr/local/mysql/lib/libmysqlclient.so.18 /usr/lib64/libmysqlclient.so.18 #可以使用设置搜索库文件的路径方式实现 [root@localhost LNMP+zabbix-3.2.1]# tail -1 /etc/ld.so.conf /usr/local/mysql/lib/ [root@localhost LNMP+zabbix-3.2.1]# ldconfig -v | grep libmysqlclient.so.18 cd ~/zabbix-3.2.1/misc/init.d/fedora/core cp zabbix_* /etc/init.d/ vim /etc/init.d/zabbix_server BASEDIR=/usr/local/zabbix vim /etc/init.d/zabbix_agentd BASEDIR=/usr/local/zabbix vim /etc/services zabbix-agent10050/tcp# Zabbix Agent zabbix-agent10050/udp# Zabbix Agent zabbix-server10051/tcp# Zabbix Trapper zabbix-server10051/udp# Zabbix Trapper vim /etc/zabbix/zabbix_server.conf DBName=zabbix DBUser=zabbix DBPassword=qwe123 LogFile=/var/log/zabbix/zabbix_server.log vim /etc/zabbix/zabbix_agentd.conf Server=127.0.0.1,192.168.100.10 ServerActive=192.168.100.10:10051 Hostname=zabbix server LogFile=/var/log/zabbix/zabbix_server.log UnsafeUserParemeters=1 cd ~/zabbix-3.2.1/frontends/ cp -r php/ /usr/local/nginx/html/zabbix chown -R nginx.nginx /usr/local/nginx/html/zabbix/ service zabbix_server start chkconfig zabbix_server on service zabbix_agentd start chkcongig zabbix_agentd on
二、zabbix客戶端部署
tar -xf zabbix-3.2.1.tar.gz yum -y install gcc useradd zabbix ./configure --prefix=/usr/local/zabbix --enable-agent && make && make install mkdir /var/log/zabbix chown zabbix.zabbix /var/log/zabbix/ cp misc/init.d/fedora/core/zabbix_agentd /etc/init.d/ chmod +x /etc/init.d/zabbix_agentd ln -s /usr/local/zabbix/etc/ /etc/zabbix ln -s /usr/local/zabbix/bin/* /usr/bin/ ln -s /usr/local/zabbix/sbin/* /usr/sbin/ vim /etc/zabbix/zabbix_agentd.conf LogFile=/var/log/zabbix/zabbix_agentd.log Server=127.0.0.1,192.168.100.10 ServerActive=192.168.100.10:10051 Hostname=zabbix client UnsafeUserParameters=1 vim /etc/init.d/zabbix_agentd BASEDIR=/usr/local/zabbix chkconfig zabbix_agentd on service zabbix_agentd start
客戶端存取:
firefox http://192.168.100.10/zabbix
預設的登陸名稱/密碼:admin/zabbix
##相關推薦:以上是LNMP和zabbix配置實例代碼分享的詳細內容。更多資訊請關注PHP中文網其他相關文章!