文章目录 配置zabbix监控nginx状态。一、搭建Discuz论坛1、配置epel源2、安装centos-release-scl源3、部署lnmp环境4、配置php-fpm5、准备论坛代码
首先搭建一套LNMP环境,部署discuz论坛用于后面监控案例。
搭建一个测试用论坛**
[root@node4 ~]# wget -O /etc/yum.repos.d/epel.repo Http://mirrors.aliyun.com/repo/epel-7.repo
[root@node4 ~]# yum install centos-release-scl -y
[root@node4 ~]# yum -y install nginx mariadb-server rh-PHP72-php rh-php72-phpcli rh-php72-php-common \rh-php72-php-fpm rh-php72-php-gd rh-php72-php-mbstring rh-php72-php-pdo \rh-php72-php-xml rh-php72-php-Mysqlnd rh-Redis5 sclo-php72-php-pecl-redis5
[root@node4 ~]# vim /etc/opt/rh/rh-php72/php-fpm.d/www.conf; Unix user/group of processes; Note: The user is mandatory. If the group is not set, the default user's group; will be used.; RPM: apache user chosen to provide access to the same directories as httpd;user = apacheuser = nginx; RPM: Keep a group allowed to write in log dir.;group = apachegroup = nginx
[root@node4 ~]# mkdir /code/discuz -p论坛代码可到官网下载:https://www.discuz.net/forum-10-1.html上传下载的Discuz_X3.3_SC_UTF8.zip[root@node4 ~]# rz -Erz waiting to receive.[root@node4 ~]# lsanaconda-ks.cfg Discuz_X3.3_SC_UTF8.zip解压到创建的指定目录下[root@node4 ~]# unzip -q Discuz_X3.3_SC_UTF8.zip -d /code/discuz/[root@node4 ~]# cd /code/discuz[root@node4 discuz]# lltotal 4drwxr-xr-x 2 root root 102 Jul 27 2017 readmedrwxr-xr-x 12 root root 4096 Jul 27 2017 uploaddrwxr-xr-x 4 root root 72 Jul 27 2017 utility修改所属组[root@node4 discuz]# chown -R nginx:nginx /code/discuz/
[root@node4 ~]# vim /etc/nginx/conf.d/discuz.confserver { listen 80; server_name discuz.kongd.com; root /code/discuz/upload; location / { index index.php index.html; } 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; }}
先停止之前的apache(没有则不用此操作):# systemctl stop httpd[root@node4 ~]# systemctl enable nginx.service mariadb.service rh-php72-php-fpm.service rh-redis5-redis.service --nowCreated symlink from /etc/systemd/system/multi-user.target.wants/nginx.service to /usr/lib/systemd/system/nginx.service.Created symlink from /etc/systemd/system/multi-user.target.wants/mariadb.service to /usr/lib/systemd/system/mariadb.service.Created symlink from /etc/systemd/system/multi-user.target.wants/rh-php72-php-fpm.service to /usr/lib/systemd/system/rh-php72-php-fpm.service.Created symlink from /etc/systemd/system/multi-user.target.wants/rh-redis5-redis.service to /usr/lib/systemd/system/rh-redis5-redis.service.
创建数据库并授权[root@node4 ~]# mysql -e "create database discuz character set utf8;"[root@node4 ~]# mysql -e "grant all on discuz.* to discuz@localhost identified by '123456';"
配置hosts解析,在线完成论坛安装
C:\windows\System32\drivers\etc\hosts
添加:192.168.43.114 discuz.kongd.com
登录>管理中心>全局>性能优化>内存优化
修改config_global.php文件
[root@node4 ~]# vim /code/discuz/upload/config/config_global.php// -------------------------- CONFIG MEMORY --------------------------- //$_config['memory']['prefix'] = 'QOatDb_';$_config['memory']['redis']['server'] = '127.0.0.1';//redis服务地址$_config['memory']['redis']['port'] = 6379;$_config['memory']['redis']['pconnect'] = 1;$_config['memory']['redis']['timeout'] = '0';$_config['memory']['redis']['requirepass'] = '';//认证密码,没配置不填$_config['memory']['redis']['serializer'] = 1;$_config['memory']['memcache']['server'] = '';$_config['memory']['memcache']['port'] = 11211;$_config['memory']['memcache']['pconnect'] = 1;
刷新查看
Nginx提供了status模块监控内部的运行状态,如需查看当前Nginx是否支持status模块,则可使用nginx -V命令查看是否输出–with_stub_status_modules。 RPM包安装默认支持,为 --withhttp_stub_status_module 。
开启Nginx状态数据配置,需要在nginx.conf中添加一个虚拟主机,内容如下
[root@node4 ~]# cat /etc/nginx/conf.d/monitor.confserver {listen 127.0.0.1:80;server_name 127.0.0.1;location /nginxstatus {stub_status on;#开启状态页access_log off;#不记录访问日志allow 127.0.0.1; #只允许自己访问,这里是允许的IP地址deny all;#其他全部拒绝}}-----------------------------------------------------------------------------------------------------------------------检查配置文件[root@node4 ~]# nginx -tnginx: the configuration file /etc/nginx/nginx.conf syntax is oknginx: configuration file /etc/nginx/nginx.conf test is successful-----------------------------------------------------------------------------------------------------------------------加载配置[root@node4 ~]# nginx -s reload-----------------------------------------------------------------------------------------------------------------------访问测试[root@node4 ~]# curl http://127.0.0.1/nginxstatusActive connections: 1 server accepts handled requests 19 19 112 Reading: 0 Writing: 1 Waiting: 0 各字段的含义:Active connections:当前活跃的客户端连接数,包括Waiting连接数;accepts:接受的客户端连接总数;handled:已处理的连接总数。通常与“accepts”的值相同,除非达到某些资源限制,如“worker_connections”;requests:客户端请求总数,一个客户端连接可能包含多个请求;Reading:Nginx正在读取请求标头的当前连接数;Writing:Nginx正在将响应写回给客户端的当前连接数;Waiting:当前等待请求的空闲连接数。
zabbix 5.0 默认提供了监控nginx模板,直接套用模板监控即可。
zabbix模板 https://www.zabbix.com/integrations?cat=official_templates
配置>主机>node4>模板>添加
注意:需取消原有连接,再添加上方模板
查看状态
修改宏变量
注意:node4需配置zabbix-agent2
配置方法——查看目录“客户端”https://blog.csdn.net/zhuangjiu/article/details/126033403?spm=1001.2014.3001.5501
完成
来源地址:https://blog.csdn.net/zhuangjiu/article/details/126128107
--结束END--
本文标题: zabbix监控nginx状态
本文链接: https://www.lsjlt.com/news/391356.html(转载时请注明来源链接)
有问题或投稿请发送至: 邮箱/279061341@qq.com QQ/279061341
下载Word文档到电脑,方便收藏和打印~
2024-02-29
2024-02-29
2024-02-29
2024-02-29
2024-02-29
2024-02-29
2024-02-29
2024-02-29
2024-02-29
2024-02-29
回答
回答
回答
回答
回答
回答
回答
回答
回答
回答
0