报错
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-06-29 00:28:57 EDT; 10s ago
Process: 909 ExecStartPre=/usr/sbin/nginx -t (code=exited, status=1/FAILURE)
Process: 905 ExecStartPre=/usr/bin/rm -f /run/nginx.pid (code=exited, status=0/SUCCESS)
6月 29 00:28:57 localhost.localdomain systemd[1]: Starting The nginx HTTP and reverse proxy server...
6月 29 00:28:57 localhost.localdomain nginx[909]: nginx: the configuration file /etc/nginx/nginx.conf syntax is ok
6月 29 00:28:57 localhost.localdomain nginx[909]: nginx: [emerg] bind() to 0.0.0.0:8100 failed (13: Permission denied)
6月 29 00:28:57 localhost.localdomain nginx[909]: nginx: configuration file /etc/nginx/nginx.conf test failed
6月 29 00:28:57 localhost.localdomain systemd[1]: nginx.service: control process exited, code=exited status=1
6月 29 00:28:57 localhost.localdomain systemd[1]: Failed to start The nginx HTTP and reverse proxy server.
6月 29 00:28:57 localhost.localdomain systemd[1]: Unit nginx.service entered failed state.
6月 29 00:28:57 localhost.localdomain systemd[1]: nginx.service failed.
解决
权限拒绝,经检查发现是开启selinux 导致的。 直接关闭
getenforce 这个命令可以查看当前是否开启了selinux 如果输出 disabled 或 permissive (宽容) 那就是关闭了
如果输出 enforcing 那就是开启了 selinux
1、临时关闭selinux
setenforce 0 ##设置SELinux 成为 permissive (宽容) 模式
setenforce 1 ##设置SELinux 成为enforcing模式
2、永久关闭selinux
修改/etc/selinux/config 文件
将SELINUX=enforcing改为SELINUX=disabled
重启系统即可