共计 1278 个字符,预计需要花费 4 分钟才能阅读完成。
问题形容
在 AWS 上以普通用户身份装置 nginx,启动时呈现无奈绑定 8201 端口的问题
● nginx.service - nginx - high performance web server
Loaded: loaded (/usr/lib/systemd/system/nginx.service; disabled; vendor preset: disabled)
Active: failed (Result: exit-code) since 一 2021-04-19 12:28:16 CST; 9s ago
Docs: http://nginx.org/en/docs/
Process: 14781 ExecStart=/usr/sbin/nginx -c /etc/nginx/nginx.conf (code=exited, status=1/FAILURE)
4 月 19 12:28:16 ip-172-31-6-83 systemd[1]: Starting nginx - high performance web server...
4 月 19 12:28:16 ip-172-31-6-83 nginx[14781]: nginx: [emerg] bind() to 0.0.0.0:8201 failed (1...ed)
4 月 19 12:28:16 ip-172-31-6-83 systemd[1]: nginx.service: control process exited, code=exite...s=1
4 月 19 12:28:16 ip-172-31-6-83 systemd[1]: Failed to start nginx - high performance web server.
4 月 19 12:28:16 ip-172-31-6-83 systemd[1]: Unit nginx.service entered failed state.
4 月 19 12:28:16 ip-172-31-6-83 systemd[1]: nginx.service failed.
问题解决
在网上搜寻到相干信息,都是提醒非用户不能操作 1024 以上的端口,跟以后问题不符,起初在博客园上找到解决方案,是跟 setlinux 无关。
[ec2-user@ip-172-31-6-83 nginx]$ sudo getenforce # 查看 setlinux 状态
Enforcing
[ec2-user@ip-172-31-6-83 nginx]$ sudo setenforce 0
[ec2-user@ip-172-31-6-83 nginx]$ sudo getenforce
Permissive
[ec2-user@ip-172-31-6-83 nginx]$ sudo systemctl start nginx
[ec2-user@ip-172-31-6-83 nginx]$ ss -tunlp | grep 8201
tcp LISTEN 0 128 *:8201 *:*
如果须要永恒敞开 selinux,请编辑 /etc/selinux/config 文件,将 SELINUX=disabled。之后将零碎重启一下即可。
vim /etc/selinux/config
原文链接
正文完