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

如何排查nginx服务启动情况,杀死端口,以及防火墙开放指定端口【linux与nginx排查手册】

利用NGINX搭建了视频服务,突然发现启动不了了,于是命令开始

  1. 使用以下命令查看更详细的错误信息:
    • systemctl status nginx.service
Warning: The unit file, source configuration file or drop-ins of nginx.service changed on disk. Run 'systemctl daemon-reload' to reload units. Job for nginx.service failed because the control process exited with error code. See "systemctl status nginx.service" and "journalctl -xe" for details. [root@raw /]# sudo systemctl daemon-reload [root@raw /]# systemctl status nginx.service ● nginx.service Loaded: loaded (/etc/systemd/system/nginx.service; bad; vendor preset: disabled) Active: failed (Result: exit-code) since Thu 2024-04-18 11:23:02 CST; 14s ago4月 18 11:23:02 raw.githubusercontent.com systemd[1]: Starting nginx.service... 4月 18 11:23:02 raw.githubusercontent.com systemd[1]: nginx.service: Control process exited, code=exited status=203 4月 18 11:23:02 raw.githubusercontent.com systemd[1]: nginx.service: Failed with result 'exit-code'. 4月 18 11:23:02 raw.githubusercontent.com systemd[1]: Failed to start nginx.service. 4月 18 11:23:12 raw.githubusercontent.com systemd[1]: /etc/systemd/system/nginx.service:1: Assignment outside of section. Ignoring. 4月 18 11:23:12 raw.githubusercontent.com systemd[1]: /etc/systemd/system/nginx.service:2: Assignment outside of section. Ignoring. 4月 18 11:23:12 raw.githubusercontent.com systemd[1]: /etc/systemd/system/nginx.service:3: Assignment outside of section. Ignoring. 4月 18 11:23:16 raw.githubusercontent.com systemd[1]: /etc/systemd/system/nginx.service:1: Missing '='. [root@raw /]# sudo systemctl start nginx Job for nginx.service failed because the control process exited with error code. See "systemctl status nginx.service" and "journalctl -xe" for details. [root@raw /]# systemctl status nginx.service ● nginx.service Loaded: loaded (/etc/systemd/system/nginx.service; bad; vendor preset: disabled) Active: failed (Result: exit-code) since Thu 2024-04-18 11:23:22 CST; 7s ago Process: 41057 ExecStart=/usr/local/nginx/sbin/nginx (code=exited, status=1/FAILURE)4月 18 11:23:21 raw.githubusercontent.com nginx[41057]: nginx: [emerg] bind() to 0.0.0.0:8090 failed (98: Address already in use) 4月 18 11:23:21 raw.githubusercontent.com nginx[41057]: nginx: [emerg] bind() to 0.0.0.0:82 failed (98: Address already in use) 4月 18 11:23:21 raw.githubusercontent.com nginx[41057]: nginx: [emerg] bind() to 0.0.0.0:8090 failed (98: Address already in use) 4月 18 11:23:21 raw.githubusercontent.com nginx[41057]: nginx: [emerg] bind() to 0.0.0.0:82 failed (98: Address already in use) 4月 18 11:23:22 raw.githubusercontent.com nginx[41057]: nginx: [emerg] bind() to 0.0.0.0:8090 failed (98: Address already in use) 4月 18 11:23:22 raw.githubusercontent.com nginx[41057]: nginx: [emerg] bind() to 0.0.0.0:82 failed (98: Address already in use) 4月 18 11:23:22 raw.githubusercontent.com nginx[41057]: nginx: [emerg] still could not bind() 4月 18 11:23:22 raw.githubusercontent.com systemd[1]: nginx.service: Control process exited, code=exited status=1 4月 18 11:23:22 raw.githubusercontent.com systemd[1]: nginx.service: Failed with result 'exit-code'. 4月 18 11:23:22 raw.githubusercontent.com systemd[1]: Failed to start nginx.service.

然后发现是端口被占用,先杀死端口吧

问题出现在尝试启动 Nginx 时遇到端口冲突导致无法绑定到指定的端口(0.0.0.0:8090 和 0.0.0.0:82)上。可以按照以下步骤解决这个问题:

  1. 查找占用端口的进程:

    • 使用以下命令查找占用端口 8090 和 82 的进程:
      sudo netstat -tuln | grep ':8090\|:82'
  2. 停止占用端口的进程:

    • 根据上一步的输出,找到占用端口的进程,并停止它们,可以使用以下命令杀死占用端口 8090 的进程(假设 PID 为 XXX):
      sudo kill XXX
  3. 修改 Nginx 配置文件:

    • 如果需要修改 Nginx 配置文件中监听的端口,可以编辑 Nginx 配置文件(通常在 /usr/local/nginx/conf/nginx.conf)并将监听端口修改为未被占用的端口,例如 8080。
  4. 重新加载 Nginx 配置并启动服务:

    • 保存修改后的配置文件,然后重新加载 Nginx 配置并尝试启动 Nginx 服务:
      sudo /usr/local/nginx/sbin/nginx -s reload
  5. 再次检查 Nginx 服务状态:

    • 使用以下命令再次检查 Nginx 服务的状态:
      systemctl status nginx

通过找到并停止占用端口的进程,修改 Nginx 配置文件中的监听端口,然后重新加载配置并启动 Nginx 服务,应该可以解决端口冲突导致的启动问题。

然后命令重启nginx

[root@raw conf]# sudo systemctl start nginx

[root@raw conf]# systemctl status nginx


● nginx.service
   Loaded: loaded (/etc/systemd/system/nginx.service; bad; vendor preset: disabled)
   Active: active (running) since Thu 2024-04-18 11:31:03 CST; 5s ago
  Process: 41932 ExecStart=/usr/local/nginx/sbin/nginx (code=exited, status=0/SUCCESS)
 Main PID: 41933 (nginx)
    Tasks: 2 (limit: 203695)
   Memory: 1.3M
   CGroup: /system.slice/nginx.service
           ├─41933 nginx: master process /usr/local/nginx/sbin/nginx
           └─41934 nginx: worker process

4月 18 11:31:03 raw.githubusercontent.com systemd[1]: Starting nginx.service...
4月 18 11:31:03 raw.githubusercontent.com systemd[1]: Started nginx.service.


 

外界还看不到视频的话,那就是防火墙拦截了,再开启端口:

要开放特定端口(例如82端口),您可以按照以下步骤在防火墙中添加规则以允许流量通过该端口:

  1. 使用 firewall-cmd 命令添加端口规则:

    • 执行以下命令以永久性地开放82端口:

      txt

      sudo firewall-cmd --zone=public --add-port=82/tcp --permanent
  2. 重新加载防火墙规则:

    • 执行以下命令以重新加载防火墙规则,使新的端口规则生效:
      sudo firewall-cmd --reload
  3. 验证端口是否已开放:

    • 您可以运行以下命令来查看防火墙规则,确认82端口已成功开放:
      sudo firewall-cmd --list-all

通过执行以上步骤,可以在防火墙中添加规则以允许流量通过82端口。

[root@raw conf]# sudo firewall-cmd --zone=public --add-port=82/tcp --permanent
success
[root@raw conf]# sudo firewall-cmd --reload
success
[root@raw conf]# sudo firewall-cmd --list-all
public (active)
  target: default
  icmp-block-inversion: no
  interfaces: ens192
  sources: 
  services: cockpit dhcpv6-client ssh
  ports: 82/tcp
  protocols: 
  forward: no
  masquerade: no
  forward-ports: 
  source-ports: 
  icmp-blocks: 
  rich rules: 
[root@raw conf]# 
 

然后成功

相关文章:

如何排查nginx服务启动情况,杀死端口,以及防火墙开放指定端口【linux与nginx排查手册】

利用NGINX搭建了视频服务,突然发现启动不了了,于是命令开始 使用以下命令查看更详细的错误信息: systemctl status nginx.service Warning: The unit file, source configuration file or drop-ins of nginx.service changed on disk. Run…...

用Rust实现免费调用ChatGPT的命令行工具 (一)

代码已经开源:🚀 fgpt 欢迎大家star⭐和fork 👏 ChatGPT现在免费提供了GPT3.5的Web访问,不需要注册就可以直接使用,但是,它的使用方式是通过Web页面,不够方便。 更多技术分享关注 入职啦&…...

mysql 查询实战1-题目

学习了mysql 查询实战-变量方式-解答-CSDN博客,接着练习sql,从实战中多练习。 1,题目: 1,查询部门工资最高的员工 1,建表: DROP TABLE IF EXISTS department; create table department(dept_i…...

Word学习笔记之奇偶页的页眉与页码设置

1. 常用格式 在毕业论文中,往往有一下要求: 奇数页右下角显示、偶数页左下角显示奇数页眉为每章标题、偶数页眉为论文标题 2. 问题解决 2.1 前期准备 首先,不论时要求 1、还是要求 2,这里我们都要做一下设置: 鼠…...

数据赋能(58)——要求:数据赋能实施部门能力

“要求:数据赋能实施部门能力”是作为标准的参考内容编写的。 在实施数据赋能中,数据赋能实施部门的能力体现在多个方面,关键能力如下图所示。 在实施数据赋能的过程中,数据赋能实施部门应具备的关键能力如下。 理性思维与逻辑分…...

Unity URP PBR_Cook-Torrance模型

Cook-Torrance模型是一个微表面光照模型,认为物体的表面可以看作是由许多个理想的镜面反射体微小平面组成的。 单点反射镜面反射漫反射占比*漫反射 漫反射 基础色/Π 镜面反射DFG/4(NV)(NL) D代表微平面分布函数,描述的是法线与半角向量normalize(L…...

Unity之XR Interaction Toolkit如何在VR中实现渐变黑屏效果

前言 做VR的时候,有时会有跳转场景,切换位置,切换环境,切换进度等等需求,此时相机的画面如果不切换个黑屏,总会感觉很突兀。刚好Unity的XR Interaction Toolkit插件在2.5.x版本,出了一个TunnelingVignette的效果,我们今天就来分析一下他是如何使用的,然后我们自己再来…...

html+vue编写分页功能

效果&#xff1a; html关键代码&#xff1a; <div class"ui-jqgrid-resize-mark" id"rs_mlist_table_C87E35BE"> </div><div class"list_component_pager ui-jqgrid-pager undefined" dir"ltr"><div id"pg…...

计算机网络 实验指导 实验17

实验17 配置无线网络实验 1.实验拓扑图 Table PC0 和 Table PC1 最开始可能还会连Access Point0&#xff0c;无影响后面会改 名称接口IP地址网关地址Router0fa0/0210.10.10.1fa0/1220.10.10.2Tablet PC0210.10.10.11Tablet PC1210.10.10.12Wireless互联网220.10.10.2LAN192.16…...

在 Vue中,v-for 指令的使用

在 Vue中&#xff0c;v-for 指令用于渲染一个列表&#xff0c;基于源数据多次渲染元素或模板块。它对于展示数组或对象中的数据特别有用。 数组渲染 假设你有一个数组&#xff0c;并且你想为每个数组元素渲染一个 <li> 标签&#xff1a; <template> <ul>…...

达梦数据库执行sql报错:数据溢出

数据库执行sql报错数据溢出 单独查询对应的数字进行计算是不是超过了某个字段类型的上限或下限 如果已经超过了&#xff0c;进行对字段进行cast类型转换处理&#xff0c;转换为dec num都可以尝试 这里就是从 max(T.BLOCK_ID as dec*8192t.bytes)/1024/1024 max_MB,换成了这个…...

从「宏大叙事」到「生活叙事」,小红书品牌种草的的“正确姿势”

不同于抖音和微博&#xff0c;在小红书上&#xff0c;品牌营销的基调应该是怎样的&#xff1f;品牌怎样与小红书用户对话&#xff1f;什么样的内容&#xff0c;才能走进小红书用户的心中&#xff1f;本期&#xff0c;小编将带大家洞察品牌在小红书营销的“正确姿势”。从「小美…...

Python Selenium 的基本使用方法

文章目录 1. 概述2. 安装Chrome及ChromeDriver2.1 安装Chrome2.2 安装ChromeDriver 3. 安装Selenium4. 常见用法4.1 启动4.2 查找元素4.3 等待页面加载元素 1. 概述 Selenium 是一个用于自动化 web 浏览器的工具&#xff0c;它提供了一套用于测试 web 应用程序的工具和库。Sel…...

上位机图像处理和嵌入式模块部署(树莓派4b固件功能设计)

【 声明&#xff1a;版权所有&#xff0c;欢迎转载&#xff0c;请勿用于商业用途。 联系信箱&#xff1a;feixiaoxing 163.com】 前面我们说过&#xff0c;上位机的功能都是基于插件进行开发的。但是上位机的成本比较贵&#xff0c;一般的企业不一定愿意接接受。这个时候另外一…...

新手入门人工智能:从零开始学习AI的正确途径

你是否对人工智能&#xff08;AI&#xff09;充满了好奇心和探索欲&#xff1f;你是否想了解如何从零开始学习AI&#xff0c;成为一名人工智能领域的专家&#xff1f;那么&#xff0c;这篇文章就是为你准备的&#xff01;我们将带你了解人工智能的基本概念&#xff0c;学习如何…...

ubuntu git相关操作

1 安装git sudo apt install git git --version git version 2.25.1 2 解决git超时 2.1 扩大post的buffer git config --global http.postBuffer 524288000 git config --global http.postBuffer 157286400 2.2 换回HTTP1上传。上传之后再切换回HTTP2 …...

IDEA工具|添加 GitLab 账户之两三事

&#x1f4eb; 作者简介&#xff1a;「六月暴雪飞梨花」&#xff0c;专注于研究Java&#xff0c;就职于科技型公司后端工程师 &#x1f3c6; 近期荣誉&#xff1a;华为云云享专家、阿里云专家博主、腾讯云优秀创作者、ACDU成员 &#x1f525; 三连支持&#xff1a;欢迎 ❤️关注…...

蓝桥杯:棋盘(Java)

目录 问题描述输入格式输出格式代码实现 问题描述 小蓝拥有n n大小的棋盘&#xff0c;一开始棋盘上全都是白子。小蓝进行了m.次操作&#xff0c;每次操作会将棋盘上某个范围内的所有棋子的颜色取反&#xff08;也就是白色棋子变为黑色&#xff0c;黑色棋子变为白色)。请输出所…...

跨界融合:ERP与TMS的区分、相通之处、融合方式,全告诉你。

Hi&#xff0c;如今系统的边界越来越模糊&#xff0c;A系统和B系统会有一些功能的交叉&#xff0c;贝格前端工场今天开始介绍第二篇ERP和TMS的融合。 一、什么是ERP和TMS ERP是企业资源规划&#xff08;Enterprise Resource Planning&#xff09;的缩写&#xff0c;是一种集成…...

SAP Smartform转存PDF方法汇总

用户会有保存SF至本地PDF文件的需求,下面详细说明一下Smartform转成PDF的四种方法,其中,方法二和三相比于其他方法更便捷实用,如果还有其他方法,欢迎留言补充。 一、代码开发 1)先调用smartform函数获取OTF格式数据 2)后调用函数CONVERT_OTF转换成PDF格式数据 3)再…...

浅谈 React Hooks

React Hooks 是 React 16.8 引入的一组 API&#xff0c;用于在函数组件中使用 state 和其他 React 特性&#xff08;例如生命周期方法、context 等&#xff09;。Hooks 通过简洁的函数接口&#xff0c;解决了状态与 UI 的高度解耦&#xff0c;通过函数式编程范式实现更灵活 Rea…...

Linux应用开发之网络套接字编程(实例篇)

服务端与客户端单连接 服务端代码 #include <sys/socket.h> #include <sys/types.h> #include <netinet/in.h> #include <stdio.h> #include <stdlib.h> #include <string.h> #include <arpa/inet.h> #include <pthread.h> …...

C++:std::is_convertible

C++标志库中提供is_convertible,可以测试一种类型是否可以转换为另一只类型: template <class From, class To> struct is_convertible; 使用举例: #include <iostream> #include <string>using namespace std;struct A { }; struct B : A { };int main…...

SCAU期末笔记 - 数据分析与数据挖掘题库解析

这门怎么题库答案不全啊日 来简单学一下子来 一、选择题&#xff08;可多选&#xff09; 将原始数据进行集成、变换、维度规约、数值规约是在以下哪个步骤的任务?(C) A. 频繁模式挖掘 B.分类和预测 C.数据预处理 D.数据流挖掘 A. 频繁模式挖掘&#xff1a;专注于发现数据中…...

【ROS】Nav2源码之nav2_behavior_tree-行为树节点列表

1、行为树节点分类 在 Nav2(Navigation2)的行为树框架中,行为树节点插件按照功能分为 Action(动作节点)、Condition(条件节点)、Control(控制节点) 和 Decorator(装饰节点) 四类。 1.1 动作节点 Action 执行具体的机器人操作或任务,直接与硬件、传感器或外部系统…...

python爬虫:Newspaper3k 的详细使用(好用的新闻网站文章抓取和解析的Python库)

更多内容请见: 爬虫和逆向教程-专栏介绍和目录 文章目录 一、Newspaper3k 概述1.1 Newspaper3k 介绍1.2 主要功能1.3 典型应用场景1.4 安装二、基本用法2.2 提取单篇文章的内容2.2 处理多篇文档三、高级选项3.1 自定义配置3.2 分析文章情感四、实战案例4.1 构建新闻摘要聚合器…...

NFT模式:数字资产确权与链游经济系统构建

NFT模式&#xff1a;数字资产确权与链游经济系统构建 ——从技术架构到可持续生态的范式革命 一、确权技术革新&#xff1a;构建可信数字资产基石 1. 区块链底层架构的进化 跨链互操作协议&#xff1a;基于LayerZero协议实现以太坊、Solana等公链资产互通&#xff0c;通过零知…...

Java多线程实现之Thread类深度解析

Java多线程实现之Thread类深度解析 一、多线程基础概念1.1 什么是线程1.2 多线程的优势1.3 Java多线程模型 二、Thread类的基本结构与构造函数2.1 Thread类的继承关系2.2 构造函数 三、创建和启动线程3.1 继承Thread类创建线程3.2 实现Runnable接口创建线程 四、Thread类的核心…...

短视频矩阵系统文案创作功能开发实践,定制化开发

在短视频行业迅猛发展的当下&#xff0c;企业和个人创作者为了扩大影响力、提升传播效果&#xff0c;纷纷采用短视频矩阵运营策略&#xff0c;同时管理多个平台、多个账号的内容发布。然而&#xff0c;频繁的文案创作需求让运营者疲于应对&#xff0c;如何高效产出高质量文案成…...

力扣热题100 k个一组反转链表题解

题目: 代码: func reverseKGroup(head *ListNode, k int) *ListNode {cur : headfor i : 0; i < k; i {if cur nil {return head}cur cur.Next}newHead : reverse(head, cur)head.Next reverseKGroup(cur, k)return newHead }func reverse(start, end *ListNode) *ListN…...