centos7 ngxin启动失败:Job for nginx.service failed(80端口被占用的解决办法)
问题描述:
(flaskApi) [root@67 flaskDemo]# service nginx start
Redirecting to /bin/systemctl start nginx.service
Job for nginx.service failed because the control process exited with error code. See "systemctl status nginx.service" and "journalctl -xe" for details.
确认问题:
当不能使用service nginx start 开启或者使用service nginx stop 关闭时,查看systemctl status nginx 会有一定的错误提示
systemctl status nginx -l
-l表示:可以展示全部错误信息,否则可能错误信息会被折叠
Hint: Some lines were ellipsized, use -l to show in full.
返回的错误提示:
从这里我们可以看出,是80端口被占用了
9月 17 14:54:21 67.59.247.60.static.bjtelecom.net nginx[25531]: nginx: [emerg] bind() to [::]:80 failed (98: Address already in use)

通过命令查看80端口被哪个进程占用了
netstat -tpnul
可以看到是httpd,这个进程需要是24小时启动了,不能关掉

所以接下来的解决办法有2种
- 修改nginx的配置文件nginx.conf指定nginx启动时使用别的端口号,例如81
- 或者杀掉占用80端口的进程,参照:centOS7杀死进程命令
查看nginx的安装目录,并找到nginx.conf的目录:
rpm -ql grep nginx

或者直接使用find命令查找 nginx.conf
(flaskApi) [root@67 flaskDemo]# find / -name nginx.conf
/etc/nginx/nginx.conf
使用nano命令编辑nginx.conf配置文件,图示中2处默认为80的端口号改为81
nano /etc/nginx/nginx.conf

另外应当注意:
service nginx start 是centos6.x的命令 , centos7.x使用 systemctl start nginx
再次启动nginx,没看到启动成功的提示信息
(flaskApi) [root@67 flaskDemo]# /bin/systemctl start nginx.service
打印一下当前的进程,可以看到nginx已经启动了,并且使用的是81端口

参照文档:
nginx 在Centos 7 版本的yum安装 和目录解释
nginx启动报错的处理办法,参照:
https://blog.csdn.net/qq_40907977/article/details/91989353
centos7 ngxin启动失败:Job for nginx.service failed(80端口被占用的解决办法)的更多相关文章
- MySQL安装过程net start mysql 启动失败 报“错误2,系统找不到文件”的解决办法
MySQL安装过程net start mysql 启动失败 报“错误2,系统找不到文件”的解决办法 错误2,系统找不到文件. 开始...运行... regedit 注册表项: HKEY_LOCAL_ ...
- apache无法正常启动,80端口被占用的解决方法
apache无法正常启动,80端口被占用的解决方法 网上的方法: 仔细查看提示: make_sock: could not bind to address 0.0.0.0:80 恍然大悟,计算机上安装 ...
- 启用nginx报错80端口被占用
最近在本机跑nginx,启动后报错,怀疑80端口被占用 netstat -ano|findstr 尝试一:查看后发现端口被一个System pid 为4的一个程序占用.我在资源管理器中尝试将Syste ...
- 启动Nginx服务失败:Job for nginx.service failed because the control process exited with error code. See "systemctl status nginx.service" and "journalctl -xe" for details.
首次接触nginx,安装完使用命令 service nignx restart 后,出现这个错误,并按照提示给出的命令查看错误详情 systemctl status nginx.service ...
- docker 启动失败 Job for docker.service failed because the control process exited with error code. See "systemctl status docker.service" and "journalctl -xe" for details.
CentOS7安装docker,安装成功后,启动失败 提示: 我们可以看到此处它提示是Failed to start Docker Application Container Engine. 于是在网 ...
- DOCKER启动失败Job for docker.service failed because the control process exited with error code. See "syste mctl status docker.service" and "journalctl -xe" for details.
[root@localhost ~]# systemctl start docker Job for docker.service failed because the control process ...
- CentOS7端口被占用的解决办法
1.根据端口号得到其占用的进程的详细信息 netstat -tlnp|grep 80tcp 0 0 192.168.33.10:80 0.0.0.0:* ...
- Windows下启动ActiveMq端口被占用的解决办法
cd /D E:\RuntimeSoft\apache-activemq-5.11.0\binactivemq.bat start结果提示:端口号被占用. Windows下查看端口号被占用开始--运行 ...
- centos7.2安装paramiko报error: command 'gcc' failed with exit status 1的解决办法
安装依赖 yum install kernel-devel libxslt-devel libffi-devel python-devel mysql-devel zlib-devel openssl ...
随机推荐
- 如何代替set get方法
博主刚刚看其他人的博客的时候,发现好多人还在用 生成set get方法 虽然是自动生成的 但是看起来很复杂,影响代码的可读性 那么有什么办法能代替set get方法吗? 当然有啦!!! 只需要导入 ...
- python主流框架简介和Django框架的使用
目录 一.手撸简易web框架 二.动静态网页 1. 静态网页 2. 动态网页 三.jinja2模板语法 1. jinja2的作用 四.python主流web框架 1. django 3. tornad ...
- Docker(3)--常用命令
1.docker -h 帮助 2.获取镜像 docker pull NAME[:TAG] [root@node3 ~]#docker pull centos:latest 3.启动Container盒 ...
- 【leetcode】1210. Minimum Moves to Reach Target with Rotations
题目如下: In an n*n grid, there is a snake that spans 2 cells and starts moving from the top left corner ...
- 【leetcode】1201. Ugly Number III
题目如下: Write a program to find the n-th ugly number. Ugly numbers are positive integers which are div ...
- Golang入门及开发环境配置
Go语言诞生背景 计算机硬件更新频繁,主流编程语言无法发挥多核多CPU的性能 软件系统复杂度不断变高,缺乏简洁高效的编程语言 C/C++运行速度快,但编译速度慢 Go语言特点 静态类型开发语言 静态: ...
- 阿里jetcache
- DevExpress.XtraGrid.Views.Grid.GridView
private void SetView() { GridView gridView = (GridView)this.DefaultView; if (gridView != null) { gri ...
- UVa 213 信息解码 (模拟 && 二进制)
题意 :对于下面这个字符串 0,00,01,10,000,001,010,011……. 首先是长度为1的串,然后是长度为2的串,以此类推.不存在全为1的串. 你的任务是编写一个程序.首先输入一个代码头 ...
- UVA 12299 线段树 ( 单点跟新 , 区间查询)
题目链接:题意:在传统的RMQ的基础上加上一个操作:shift(i1,i2,i3...ik),表示将这些元素,依次向左移动一位(训练指南247页) #include <iostream> ...