想建立一个测试用的虚拟主机,遇到了这个问题:
[root@localhost 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

这个两个命令一是查看,一个是添加,添加完再查看一遍,如果有81,则成功。另可能要以root用户运行。

此外,如果要外网访问,还要打开linux的防火墙:

[root@localhost html]# vim /etc/sysconfig/iptables
[root@localhost html]# service iptables restart

重启apache.

相关资料:

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.

So if you executed

semanage port -l | grep http
http_cache_port_t tcp 3128, 8080, 8118
http_cache_port_t udp 3130
http_port_t tcp 80, 443, 488, 8008, 8009, 8443
pegasus_http_port_t tcp 5988
pegasus_https_port_t tcp 5989

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.

This generates an AVC that looks like

----
time->Tue Dec 12 17:37:49 2006
type=SYSCALL msg=audit(1165963069.248:852): arch=40000003 syscall=102 success=no exit=-13 a0=2 a1=bf96a830 a2=b5b1e8 a3=9e58b68 items=0 ppid=21133 pid=21134 auid=3267 uid=0 gid=0 euid=0 suid=0 fsuid=0 egid=0 sgid=0 fsgid=0 tty=pts10 comm="httpd" exe="/usr/sbin/httpd" subj=user_u:system_r:httpd_t:s0 key=(null)
type=AVC msg=audit(1165963069.248:852): avc: denied { name_bind } for pid=21134 comm="httpd" src=81 scontext=user_u:system_r:httpd_t:s0 tcontext=system_u:object_r:reserved_port_t:s0 tclass=tcp_socket

To fix this you can use semanage to add the port

semanage port -a -t http_port_t -p tcp 81

service httpd start
Starting httpd: [ OK ]

linux 下apche无法监听端口解决办法(Permission denied: make_sock: could not bind to address)的更多相关文章

  1. Windows下修改Oracle监听端口

    先放开防火墙的端口,再来改监听端口. 只有一个实例: net stop OracleOraDb11g_home1TNSListener 再运行 NET Manager 修改实例名与Listener的端 ...

  2. ora-12541:tns: 无监听程序解决办法

    1.首先找到 Oracle 安装文件 中 listener.ora文件与tnsnames.ora文件: 列如:路径:E:\app\当前系统的账户名\product\11.2.0\dbhome_1\NE ...

  3. Linux下修改Oracle监听地址

    如果你的服务器换了ip怎么办? 如果你的服务器换了名字怎么办? 以前的小伙伴怎么办? 以前的老客户怎么办? 没关系,简单教你修改监听地址,老朋友随便找! 想要修改监听地址首先要找到两个文件,确定两样东 ...

  4. vue双向数据绑定对于数组和新增对象属性不能监听的解决办法

    出现数组不能按照索引进行跟新的原因是处于性能考虑的,但是整体数组的增加删除是可以监听到的:对于对象新增属性不能监听是因为没有在生成vue实例时候放进watcher收集依赖. 首先我们先来了解vue数据 ...

  5. linux下QT Creator常见错误及解决办法

    最近因为在做一个关于linux下计算机取证的小项目,需要写一个图形界面,所以想到了用QT来写,选用了linux下的集成开发环境QT Creator5.5.1,但刚刚安装好,竟然连一个"hel ...

  6. ORA-12541:TNS:无监听程序 解决办法

    昨天我在一台win7笔记本中安装了oracle11g,然后打算用另一个win10的笔记本使用plsql developer局域网内连接访问oracle数据库.但是遇到ORA-12541:TNS:无监听 ...

  7. aes加密在linux下会生成随机key的解决办法

    直接贴代码了: package com.segerp.tygl.weixin.common; import java.io.UnsupportedEncodingException; import j ...

  8. ORA-12541:无监听错误解决办法

    http://jingyan.baidu.com/article/03b2f78c7a0ab75ea237ae33.html   1. 从开始菜单中打开“Oracle Net Configuratio ...

  9. windows和linux下读取文件乱码的终极解决办法!

    乱码是个很恶心的问题. windows和linux读取txt文件,一旦读取了,编码发生改变,就无法再还原了,只有重启项目. 网上有很多方法都是读取文件头,方法很好,但是亲测都不能用(右移8位判断0xf ...

随机推荐

  1. WPF的布局-Grid(表格布局)

    1. Grid布局就是表格布局 如下图: 2. 使用方法 2.1. 先生成适量的行和列,代码如下: <Grid><!--使用Grid控件--> <Grid.ColumnD ...

  2. 深入理解Solaris X64系统调用

    理解系统调用的关键在于洞悉系统调用号是联系用户模式与内核模式的纽带.而在Solaris x64平台上,系统调用号被保存在寄存器RAX中,从用户模式传递到内核模式.一旦进入内核模式,内核的sys_sys ...

  3. java文件在没有安装jdk的windows下运行。

    1.首先该工程最好是gui的,使用swing或者awt的都行. 2.使用eclipse打包jar文件. 项目名字上面点右键,选择Export,在选择java\JAR file.    选择src文件夹 ...

  4. [PY3]——求TopN/BtmN 和 排序问题的解决

    需求 K长的序列,求TopN K长的序列,求BtmN 排序问题 解决 heap.nlargest().heap.nsmallest( ) sorted( )+切片 max( ).min( ) 总结和比 ...

  5. log4j 详细讲解

    日志是应用软件中不可缺少的部分,Apache的开源项目log4j是一个功能强大的日志组件,提供方便的日志记录.在apache网站:jakarta.apache.org/log4j 可以免费下载到Log ...

  6. 1.http请求编程-->基础原理

    一.技术分析 打开网页,不管我们请求的是静态资源还是动态资源,IIS都会根据ISAPI(微软和Process软件公司联合提出的Web服务器上的API标准)这一标准,将请求的文件根据文件后缀名的不同,转 ...

  7. 总结—angularjs项目

    我毕业了-------有点期待生活,又点害怕生活. 总结下最近一个月做的这个项目,项目的开发形式也比较新颖,采用的是前后端分离的形式.我负责前端的管理系统开发,另一个哥们负责利用ABP创建接口,整合后 ...

  8. Spring boot Mybatis 整合(注解版)

    之前写过一篇关于springboot 与 mybatis整合的博文,使用了一段时间spring-data-jpa,发现那种方式真的是太爽了,mybatis的xml的映射配置总觉得有点麻烦.接口定义和映 ...

  9. System.arraycopy的测试

    ArrayList的源码中数组的拷贝用到该方法: public static void arraycopy(Object src, --源数组 int srcPos, --源数组要复制的起始位置 Ob ...

  10. 在JSP中将EXEL文件的数据传入到数据库中

    在jsp中: 在script中使用函数: $(function(){ //var lpyear = document.getElementById("lpyear").value; ...