Linux配置Nginx报错Failed to start The nginx HTTP and reverse proxy server

6 篇文章 0 订阅
4 篇文章 1 订阅

问题描述

需要给一台http服务器配置nginx,最终想要使用https访问到这台http主机。
配置过程:https://blog.csdn.net/zhengaog/article/details/119485385?spm=1001.2014.3001.5501
在这里插入图片描述

当前服务正常运行,本地正常访问。

安装过程如下

1:使用指令 yum install -y nginx
提示没有可用的软件包nginx
2:使用指令 yum install epel-release
重新安装yum源
安装完成使用指令查看 yum list | grep nginx
3:使用指令安装 yum install nginx
安装完成启动nginx
4:使用指令启动 service nginx start
启动成功,页面80端口正常访问
5:修改配置文件
找到配置文件 find / -name nginx.conf
打开并修改 vim /etc/nginx/nginx.conf
在这里插入图片描述
保存好。
6:重启Nginx
报错信息如下:
 nginx.service - The nginx HTTP and reverse proxy server
   Loaded: loaded (/usr/lib/systemd/system/nginx.service; enabled; vendor preset: disabled)
   Active: failed (Result: exit-code) since 一 2022-08-01 16:51:55 CST; 2s ago
  Process: 20674 ExecStartPre=/usr/sbin/nginx -t (code=exited, status=1/FAILURE)
  Process: 20670 ExecStartPre=/usr/bin/rm -f /run/nginx.pid (code=exited, status=0/SUCCESS)
 Main PID: 12937 (code=exited, status=0/SUCCESS)

801 16:51:55 Coral-File-Server systemd[1]: Starting The nginx HTTP and reverse proxy server...
801 16:51:55 Coral-File-Server nginx[20674]: nginx: the configuration file /etc/nginx/nginx.conf syntax is ok
801 16:51:55 Coral-File-Server nginx[20674]: nginx: [emerg] bind() to 0.0.0.0:10443 failed (13: Permission denied)
801 16:51:55 Coral-File-Server nginx[20674]: nginx: configuration file /etc/nginx/nginx.conf test failed
801 16:51:55 Coral-File-Server systemd[1]: nginx.service: control process exited, code=exited status=1
801 16:51:55 Coral-File-Server systemd[1]: Failed to start The nginx HTTP and reverse proxy server.
801 16:51:55 Coral-File-Server systemd[1]: Unit nginx.service entered failed state.
801 16:51:55 Coral-File-Server systemd[1]: nginx.service failed.

在这里插入图片描述

分析问题

801 16:51:55 Coral-File-Server nginx[20674]: nginx: [emerg] bind() to 0.0.0.0:10443 failed (13: Permission denied)

提示没有权限。
使用指令sudo service nginx start启动仍然提示没有权限。
使用指令getenforce查看selinux状态
在这里插入图片描述

使用指令setenforce 0 临时关闭selinux,关闭完之后重启nginx ,启动成功。

解决问题

永久关闭selinux

  1. 使用指令sed -i 's/^ *SELINUX=enforcing/SELINUX=disabled/g' /etc/selinux/config 永久关闭selinux
  2. 通过编辑selinux的文件来进行修改
    使用指令打开文件vim /etc/sysconfig/selinux
    selinux给注释掉即可。

重启整个系统

使用指令shutdown -r now重新启动系统。
重启完getenforce查看selinux状态
在这里插入图片描述

重启Nginx

系统启动完成之后,重启Nginx。
在这里插入图片描述

https://…:10443/正常访问http://…8089/的内容。

欢迎指正补充。

  • 1
    点赞
  • 6
    收藏
    觉得还不错? 一键收藏
  • 1
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论 1
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值