LNMP和zabbix配置实例代码分享

小云云
发布: 2023-03-20 16:16:01
原创
1359 人浏览过

本文主要和大家分享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

相关推荐:

centos7安装zabbix的详细介绍

Zabbix监控Linux主机设置方法

LNMP编译安装PHP以及LNMP配置和验证实例分享

以上是LNMP和zabbix配置实例代码分享的详细内容。更多信息请关注PHP中文网其他相关文章!

相关标签:
来源:php.cn
本站声明
本文内容由网友自发贡献,版权归原作者所有,本站不承担相应法律责任。如您发现有涉嫌抄袭侵权的内容,请联系admin@php.cn
热门教程
更多>
最新下载
更多>
网站特效
网站源码
网站素材
前端模板