当前位置: 首页 > news >正文

源码编译安装,及nginx服务控制、监控块

1.源码编译安装:

[root@17dns ~]# wget https://nginx.org/download/nginx-1.27.0.tar.gz

2.解压:

[root@17dns ~]# tar -zxvf nginx-1.27.0.tar.gz

3.安装gcc等工具

[root@17dns ~]# yum -y install gcc gcc-c++ 

[root@17dns ~]# yum -y install make lrzsz openssl-devel pcre-devel

4.编译,配置文件

[root@17dns ~]# cd nginx-1.27.0/
[root@17dns nginx-1.27.0]# ./configure --prefix=/usr/local/nginx --user=nginx --group=nginx --with-http_ssl_module --with-http_stub_status_module --with-http_realip_module --with-stream

[root@17dns nginx-1.27.0]# make && make install

[root@17dns nginx-1.27.0]# useradd -s /bin/nologin -M nginx

5.检查目录:

[root@17dns nginx-1.27.0]# tree /usr/local/nginx/

5.查看文件:

[root@17dns nginx-1.27.0]# cd /usr/local/nginx/
[root@17dns nginx]# ls
conf  html  logs  sbin

6.启服务

[root@17dns nginx]# ./sbin/nginx 
nginx: [emerg] bind() to 0.0.0.0:80 failed (98: Address already in use)
nginx: [emerg] bind() to 0.0.0.0:80 failed (98: Address already in use)
nginx: [emerg] bind() to 0.0.0.0:80 failed (98: Address already in use)
nginx: [emerg] bind() to 0.0.0.0:80 failed (98: Address already in use)
nginx: [emerg] bind() to 0.0.0.0:80 failed (98: Address already in use)
nginx: [emerg] still could not bind()
[root@17dns nginx]# 

6.主配置文件:

[root@17dns nginx]# vim /usr/local/nginx/conf/nginx.conf

7.nginx服务控制:

[root@17dns nginx]# nginx
-bash: nginx: 未找到命令
[root@17dns nginx]# ln -s /usr/local/nginx/sbin/nginx /usr/bin/
[root@17dns nginx]# ls -l /usr/bin/nginx 
lrwxrwxrwx. 1 root root 27 7月  29 16:15 /usr/bin/nginx -> /usr/local/nginx/sbin/nginx
[root@17dns nginx]# nginx
nginx: [emerg] bind() to 0.0.0.0:80 failed (98: Address already in use)
nginx: [emerg] bind() to 0.0.0.0:80 failed (98: Address already in use)
nginx: [emerg] bind() to 0.0.0.0:80 failed (98: Address already in use)
nginx: [emerg] bind() to 0.0.0.0:80 failed (98: Address already in use)
nginx: [emerg] bind() to 0.0.0.0:80 failed (98: Address already in use)
nginx: [emerg] still could not bind()
[root@17dns nginx]# 

8. 用systemctl 启用nginx

[root@17dns nginx]# vim /usr/lib/systemd/system/nginx.service
[root@17dns nginx]# cat /usr/lib/systemd/system/nginx.service
[Unit]
Description=nginx
After=network.target

[Service]
Type=forking
PIDFile=/usr/local/nginx/logs/nginx.pid
ExecStart=/usr/local/nginx/sbin/nginx
ExecReload=/usr/local/nginx/sbin/nginx -s reload
ExecStop=/usr/local/nginx/sbin/nginx -s stop
PrivateTmp=Flase

[Install]
WantedBy=multi-user.target
[root@17dns nginx]# systemctl daemon-reload 
[root@17dns nginx]# reboot

只能重启后使用

9.添加监控块:

[root@17dns ~]# vim /usr/local/nginx/conf/nginx.conf

在47行加:

        location /status{
                stub_status on;
                access_log off;
        }

[root@17dns ~]# systemctl restart nginx.service

监听测试,主机在访问一次192.168.2.17

http://www.lryc.cn/news/410270.html

相关文章:

  • 在react中使用wangeditor富文本
  • 拉提查合创5步玩转git工具协作代码开发
  • React特点
  • 鸿蒙(HarmonyOS)自定义Dialog实现时间选择控件
  • 学习008-02-04-08 Localize UI Elements(本地化UI元素)
  • 如何系统的学习C++和自动驾驶算法
  • typescript 定义类
  • 认证授权概述和SpringSecurity安全框架快速入门
  • docker常用命令集锦
  • 学习Java的日子 Day56 数据库连接池,Druid连接池
  • 如何实现PostgreSQL对某一张表的WAL日志进行记录
  • 机器学习数学基础(2)--最大似然函数
  • 详解 @RequestHeader 注解在 Spring Boot 中的使用
  • C# 表达式树的简介与说明
  • 【北京迅为】《i.MX8MM嵌入式Linux开发指南》-第三篇 嵌入式Linux驱动开发篇-第六十三章 输入子系统实验
  • [补题记录]Leetcode 15. 三数之和
  • 什么是sql注入攻击,如何预防介绍一下mysql中的常见数据类型
  • 史上最全的Seata教学并且连接springcloudAlibaba进行使用
  • InternLM Git 基础知识
  • 【Unity模型】古代亚洲建筑
  • 木马后门实验
  • 【React】useState:状态更新规则详解
  • C#中的异步编程:Task、Await 和 Async
  • SSRF-labs-master靶场
  • HBuilder X中配置vue-cli项目和UI库
  • 如何用PostMan按照规律进行循环访问接口
  • 稳态准直太阳光模拟器仪器光伏电池组件IV测试
  • vue3 reactive原理(二)-代理Set和Map及ref原理
  • Python自然语言处理库之NLTK与spaCy使用详解
  • Hive-内部表和外部表