centos7解决修改httpd端口无法重启问题

By Heanny
2019-3-8
6866 read

报错信息

[root@localhost ~]# 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 五 2019-03-08 13:52:42 CST; 53s ago
     Docs: man:httpd(8)
           man:apachectl(8)
  Process: 59491 ExecStop=/bin/kill -WINCH ${MAINPID} (code=exited, status=1/FAILURE)
  Process: 59489 ExecStart=/usr/sbin/httpd $OPTIONS -DFOREGROUND (code=exited, status=1/FAILURE)
 Main PID: 59489 (code=exited, status=1/FAILURE)

3月 08 13:52:42 localhost.localdomain httpd[59489]: (13)Permission denied: AH00072: make_sock: could not bind to address [::]:1220
3月 08 13:52:42 localhost.localdomain httpd[59489]: (13)Permission denied: AH00072: make_sock: could not bind to address 0.0.0.0:1220
3月 08 13:52:42 localhost.localdomain httpd[59489]: no listening sockets available, shutting down
3月 08 13:52:42 localhost.localdomain httpd[59489]: AH00015: Unable to open logs
3月 08 13:52:42 localhost.localdomain systemd[1]: httpd.service: main process exited, code=exited, status=1/FAILURE
3月 08 13:52:42 localhost.localdomain kill[59491]: kill: cannot find process ""
3月 08 13:52:42 localhost.localdomain systemd[1]: httpd.service: control process exited, code=exited status=1
3月 08 13:52:42 localhost.localdomain systemd[1]: Failed to start The Apache HTTP Server.
3月 08 13:52:42 localhost.localdomain systemd[1]: Unit httpd.service entered failed state.
3月 08 13:52:42 localhost.localdomain systemd[1]: httpd.service failed.


这是由于SELinux引发的问题,然后运用临时禁止即可启动成功。现记录至此以备以后运用。

临时禁用

# setenforce 0

修改配置文件需要重启机器:

修改/etc/selinux/config 文件

将SELINUX=enforcing改为SELINUX=disabled

重启机器即可


(这里是不建议禁用的)


下面是解决方法


>>firewall-cmd --permanent --zone=public --add-port=2201/tcp  #修改防火墙
>>success
>>firewall-cmd --reload
>>semanage port -a -t http_port_t -p tcp 2201 #主要语句


查看端口情况

semanage port -l
netstat -tunlp


如果semanage报错那就运行

yum -y install policycoreutils-python.x86_64




SELinux 允许php连接数据库(远程)

setsebool -P httpd_can_network_connect 1


python如何将自己写的代码打包供他人使用
轻量级论坛

Comments

暂无评论,还不快来坐沙发...

Leave a Reply