问题描述
需要给一台http服务器配置nginx,最终想要使用https访问到这台http主机。
配置过程:https://blog.csdn.net/zhengaog/article/details/119485385?spm=1001.2014.3001.5501
当前服务正常运行,本地正常访问。
安装过程如下
-
1:使用指令
- 提示没有可用的软件包nginx 2:使用指令
-
重新安装yum源
安装完成使用指令查看yum list | grep nginx
3:使用指令安装
- 安装完成启动nginx 4:使用指令启动
- 启动成功,页面80端口正常访问 5:修改配置文件
-
找到配置文件
find / -name nginx.conf
-
打开并修改
vim /etc/nginx/nginx.conf
保存好。
6:重启Nginx
- 报错信息如下:
yum install -y nginx
yum install epel-release
yum install nginx
service nginx start
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)
8月 01 16:51:55 Coral-File-Server systemd[1]: Starting The nginx HTTP and reverse proxy server...
8月 01 16:51:55 Coral-File-Server nginx[20674]: nginx: the configuration file /etc/nginx/nginx.conf syntax is ok
8月 01 16:51:55 Coral-File-Server nginx[20674]: nginx: [emerg] bind() to 0.0.0.0:10443 failed (13: Permission denied)
8月 01 16:51:55 Coral-File-Server nginx[20674]: nginx: configuration file /etc/nginx/nginx.conf test failed
8月 01 16:51:55 Coral-File-Server systemd[1]: nginx.service: control process exited, code=exited status=1
8月 01 16:51:55 Coral-File-Server systemd[1]: Failed to start The nginx HTTP and reverse proxy server.
8月 01 16:51:55 Coral-File-Server systemd[1]: Unit nginx.service entered failed state.
8月 01 16:51:55 Coral-File-Server systemd[1]: nginx.service failed.
分析问题
8月 01 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
- 使用指令
sed -i 's/^ *SELINUX=enforcing/SELINUX=disabled/g' /etc/selinux/config
永久关闭selinux - 通过编辑selinux的文件来进行修改
使用指令打开文件vim /etc/sysconfig/selinux
把selinux
给注释掉即可。
重启整个系统
使用指令shutdown -r now
重新启动系统。
重启完getenforce
查看selinux状态
重启Nginx
系统启动完成之后,重启Nginx。
https://…:10443/正常访问http://…8089/的内容。
欢迎指正补充。