linux 下apche无法监听端口解决办法(Permission denied: make_sock: could not bind to address)
想建立一个测试用的虚拟主机,遇到了这个问题:
[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)的更多相关文章
- Windows下修改Oracle监听端口
先放开防火墙的端口,再来改监听端口. 只有一个实例: net stop OracleOraDb11g_home1TNSListener 再运行 NET Manager 修改实例名与Listener的端 ...
- ora-12541:tns: 无监听程序解决办法
1.首先找到 Oracle 安装文件 中 listener.ora文件与tnsnames.ora文件: 列如:路径:E:\app\当前系统的账户名\product\11.2.0\dbhome_1\NE ...
- Linux下修改Oracle监听地址
如果你的服务器换了ip怎么办? 如果你的服务器换了名字怎么办? 以前的小伙伴怎么办? 以前的老客户怎么办? 没关系,简单教你修改监听地址,老朋友随便找! 想要修改监听地址首先要找到两个文件,确定两样东 ...
- vue双向数据绑定对于数组和新增对象属性不能监听的解决办法
出现数组不能按照索引进行跟新的原因是处于性能考虑的,但是整体数组的增加删除是可以监听到的:对于对象新增属性不能监听是因为没有在生成vue实例时候放进watcher收集依赖. 首先我们先来了解vue数据 ...
- linux下QT Creator常见错误及解决办法
最近因为在做一个关于linux下计算机取证的小项目,需要写一个图形界面,所以想到了用QT来写,选用了linux下的集成开发环境QT Creator5.5.1,但刚刚安装好,竟然连一个"hel ...
- ORA-12541:TNS:无监听程序 解决办法
昨天我在一台win7笔记本中安装了oracle11g,然后打算用另一个win10的笔记本使用plsql developer局域网内连接访问oracle数据库.但是遇到ORA-12541:TNS:无监听 ...
- aes加密在linux下会生成随机key的解决办法
直接贴代码了: package com.segerp.tygl.weixin.common; import java.io.UnsupportedEncodingException; import j ...
- ORA-12541:无监听错误解决办法
http://jingyan.baidu.com/article/03b2f78c7a0ab75ea237ae33.html 1. 从开始菜单中打开“Oracle Net Configuratio ...
- windows和linux下读取文件乱码的终极解决办法!
乱码是个很恶心的问题. windows和linux读取txt文件,一旦读取了,编码发生改变,就无法再还原了,只有重启项目. 网上有很多方法都是读取文件头,方法很好,但是亲测都不能用(右移8位判断0xf ...
随机推荐
- 原子操作类AtomicInteger详解
为什么需要AtomicInteger原子操作类?对于Java中的运算操作,例如自增或自减,若没有进行额外的同步操作,在多线程环境下就是线程不安全的.num++解析为num=num+1,明显,这个操作不 ...
- Python处理文件和查漏
import os,re def change_filename(root): ''' 批量修改excel文件名 ''' for root_,_, fs in os.walk(root): for f ...
- Jmeter测试计划中的元素
测试计划中的元素(elements of a test plan) 本节描述测试计划不同的部分. 最小测试将包括测试计划.线程组和一个或多个采样器. 1 测试计划(Test Plan) 测试计划对象有 ...
- Jmeter性能测试之添加思考时间
利用定时器添加用户思考时间 JMeter如何插入思考时间,在一个真实的性能测试场景中,是需要加入思考时间,来模拟真实用户行为.本文就来介绍,如何在三个请求之间添加思考时间. 1. 在Test Plan ...
- 如何下载Red Hat Enterprise Linux系统
关于如何下载Red Hat Enterprise Linux系统? 这是一个既简单,又复杂的问题.简单是因为我以为她很简单,复杂是因为下载的过程有点复杂的. 相信去Oracle官网下载过东西的同学对下 ...
- vue(2.0)+vue-router(2.0)+vuex(2.0)实战
好久没更新自己的知识库,刚好借双十一的契机,用上了vue(2.0)+vue-router(2.0)+vuex(2.0)来开发公司的双十一电商活动. 项目目录结构: 运行: npm install np ...
- springboot定时任务,去掉指定日期
今天用springboot写到一个需求:每周定时发送任务,但是要避开法定节假日. 网上找了些博客看,主要参考了https://www.cnblogs.com/lic309/p/4089633.html ...
- [转].NET Core dotnet 命令大全
本文转自:http://www.cnblogs.com/linezero/p/dotnet.html https://docs.microsoft.com/en-us/dotnet/articles/ ...
- 从代码层读懂 Java HashMap 的实现原理
概述 Hashmap继承于AbstractMap,实现了Map.Cloneable.Java.io.Serializable接口.它的key.value都可以为null,映射不是有序的.Hashmap ...
- Hadoop实战之二~ hadoop作业调度详解(1)
对Hadoop的最感兴趣的地方,也就在于Hadoop的作业调度了,在正式介绍如何搭建Hadoop之前,深入理解一下Hadoop的作业调度很有必要.我们不一定能用得上Hadoop,但是如果理通顺Hado ...