apache2.x修改默认端口后报 Starting httpd: (13)Permission denied: make_sock: could not bind to address...

本文介绍了两种解决由SELinux引起的问题的方法:一是禁用SELinux;二是通过安装semanage并添加特定端口来精确配置SELinux策略。

该问题是由SELinux 引起的.(注本人的环境为centos 6.0)

解决办法有两个:

1.快速解决(不推荐)


vi /etc/sysconfig/selinux SELINUX=enforcing =>SELINUX=disabled reboot

2.从根上解决(推荐)

根据自己的需求在selinux中添加需要指定的端口


a)前提需要先安装semanage(Centos6.0默认没有安装该应用)

安装方式参看 RHEL 6: semanage SELinux Command Not Found

也可以参看http://wiki.centos.org/HowTos/SELinux

# yum provides /usr/sbin/semanage or #yum whatprovides /usr/sbin/semanage #yum -y install policycoreutils-python #semanage
b)使用semanage添加apache侦听的端口

参看http://hi.baidu.com/5212521/blog/item/0b998b1bdb15c7018618bf8c.htmlhttp://hi.baidu.com/ldtrain/blog/item/59c9bb1e242247fee0fe0b5b.html

查看现在的支持http的端口有哪些

#semanage port -l|grep http

为http服务添加新的端81

#semanage port -a -t http_port_t -p tcp 81

查看添加的结果

#semanage port -l|grep http

[root@localhost ally]# systemctl status httpd.service ● httpd.service - The Apache HTTP Server Loaded: loaded (/usr/lib/systemd/system/httpd.service; disabled; vendor preset: disabled) Active: failed (Result: exit-code) since 二 2025-07-01 18:34:41 CST; 2min 29s ago Docs: man:httpd(8) man:apachectl(8) Process: 114971 ExecStop=/bin/kill -WINCH ${MAINPID} (code=exited, status=0/SUCCESS) Process: 114982 ExecStart=/usr/sbin/httpd $OPTIONS -DFOREGROUND (code=exited, status=1/FAILURE) Main PID: 114982 (code=exited, status=1/FAILURE) 7月 01 18:34:41 localhost.localdomain systemd[1]: Starting The Apache HTTP Server... 7月 01 18:34:41 localhost.localdomain httpd[114982]: AH00558: httpd: Could not reliably determine the server's...sage 7月 01 18:34:41 localhost.localdomain httpd[114982]: (13)Permission denied: AH00072: make_sock: could not bind...8081 7月 01 18:34:41 localhost.localdomain httpd[114982]: (13)Permission denied: AH00072: make_sock: could not bind...8081 7月 01 18:34:41 localhost.localdomain httpd[114982]: no listening sockets available, shutting down 7月 01 18:34:41 localhost.localdomain httpd[114982]: AH00015: Unable to open logs 7月 01 18:34:41 localhost.localdomain systemd[1]: httpd.service: main process exited, code=exited, status=1/FAILURE 7月 01 18:34:41 localhost.localdomain systemd[1]: Failed to start The Apache HTTP Server. 7月 01 18:34:41 localhost.localdomain systemd[1]: Unit httpd.service entered failed state. 7月 01 18:34:41 localhost.localdomain systemd[1]: httpd.service failed. Hint: Some lines were ellipsized, use -l to show in full.
07-02
评论
成就一亿技术人!
拼手气红包6.0元
还能输入1000个字符
 
红包 添加红包
表情包 插入表情
 条评论被折叠 查看
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值