篇首语:本文由小常识网(cha138.com)小编为大家整理,主要介绍了linux 下apche无法监听端口解决办法(Permission denied: make_sock: could not bind to address)相关的知识,希望对你有一定的参考价值。
想建立一个测试用的虚拟主机,遇到了这个问题: [[email protected]html]# service httpd start Starting httpd: httpd: Could not reliably determine the server‘s fully qualified domain name, using localhost.termwikidev for ServerName (13)Permission denied: make_sock: could not bind to address [::]:81 (13)Permission denied: make_sock: could not bind to address 0.0.0.0:81 no listening sockets available, shutting down Unable to open logs
解决办法:
semanage port -l|grep http semanage port -a -t http_port_t -p tcp 81
starting httpd 13 permission denied make_sock could not bind to address2010年01月19日 星期二 11:33In Fedora Core 5/6 and RHEL 5. We have made it easier to customize certain common parts of SELinux. In previous releases of SELinux if you wanted to change simple things like which port a daemon could listen to, you would need to write policy. Now we have the semanage utility.
SELinux assigns types to all network ports on a system. By default all ports are less then 1024 are labeled reserved_port_t and all ports > 1024 are labeled port_t. If a port is assigned to a particular type say the http port 80, it has an assigned type of http_port_t. If you want to look at all the assigned ports in SELinux, you can use the semanage tool, semanage port -l.
Here we see http_port_t is assigned to ports 80, 443, 488, 8008, 8009, 8443
The policy is written to allow httpd_t http_port_t:tcp_socket name_bind;
This means the apache command can "bind" to an port that is labeled http_port_t.
So lets say you want to run httpd on port 81.
So you edit /etc/httpd/http.conf
and change this line Listen 80 to Listen 81
Now restart the daemon. service httpd restart Stopping httpd: [ OK ] Starting httpd: (13)Permission denied: make_sock: could not bind to address [::]:81 (13)Permission denied: make_sock: could not bind to address 0.0.0.0:81 no listening sockets available, shutting down Unable to open logs [FAILED]
Now the daemon fails to start because it can not bind to port 81.