linux-虚拟机重置http监听端口并安装http失败

http的监听端口为80,为了集群安全,修改http的监听端口。修改http.conf中的监听端口为8010,启动报错。

1.“msg”:”Aborting, target uses selinux but python bindings (libselinux-python) aren’t installed!”

解决办法:

[root@lisery01 cm]# yum install  libselinux-python

2.继续执行仍然报错:”msg”: “Unable to start service httpd: Job for httpd.service failed because the control process exited with error code. See \”systemctl status httpd.service\” and \”journalctl -xe\” for details.\n”

查看http的状态:

[root@lisery01 cm]# service httpd status
Redirecting to /bin/systemctl status  ntpd.service
Unit ntpd.service could not be found.
[root@lisery01 cm]# systemctl status httpd.service
● httpd.service - The Apache HTTP Server
   Loaded: loaded (/usr/lib/systemd/system/httpd.service; enabled; vendor preset: disabled)
   Active: failed (Result: exit-code) since 二 2018-05-08 14:35:57 CST; 2min 20s ago
     Docs: man:httpd(8)
           man:apachectl(8)
  Process: 10371 ExecStop=/bin/kill -WINCH ${MAINPID} (code=exited, status=1/FAILURE)
  Process: 10370 ExecStart=/usr/sbin/httpd $OPTIONS -DFOREGROUND (code=exited, status=1/FAILURE)
 Main PID: 10370 (code=exited, status=1/FAILURE)

5月 08 14:35:57 lisery01 httpd[10370]: (13)Permission denied: AH00072: make_sock: could not bind to address [::]:8010
5月 08 14:35:57 lisery01 httpd[10370]: (13)Permission denied: AH00072: make_sock: could not bind to address 0.0.0.0:8010
5月 08 14:35:57 lisery01 httpd[10370]: no listening sockets available, shutting down
5月 08 14:35:57 lisery01 httpd[10370]: AH00015: Unable to open logs
5月 08 14:35:57 lisery01 systemd[1]: httpd.service: main process exited, code=exited, status=1/FAILURE
5月 08 14:35:57 lisery01 kill[10371]: kill: cannot find process ""
5月 08 14:35:57 lisery01 systemd[1]: httpd.service: control process exited, code=exited status=1
5月 08 14:35:57 lisery01 systemd[1]: Failed to start The Apache HTTP Server.
5月 08 14:35:57 lisery01 systemd[1]: Unit httpd.service entered failed state.
5月 08 14:35:57 lisery01 systemd[1]: httpd.service failed.

启动http:

[root@lisery01 ~]# systemctl start httpd.service
Job for httpd.service failed because the control process exited with error code. See "systemctl status httpd.service" and "journalctl -xe" for details.

发现报错,执行journalctl -xe查看系统日志:

[root@lisery01 ~]# journalctl -xe
-- Support: http://lists.freedesktop.org/mailman/listinfo/systemd-devel
-- 
-- Unit session-1.scope has begun starting up.
5月 08 16:23:40 lisery01 sshd[1932]: pam_unix(sshd:session): session opened for user root by (uid=0)
5月 08 16:25:36 lisery01 polkitd[561]: Registered Authentication Agent for unix-process:1953:13585 (system bus name :1.14 [/usr/bin/pktty
5月 08 16:25:36 lisery01 systemd[1]: Starting The Apache HTTP Server...
-- Subject: Unit httpd.service has begun start-up
-- Defined-By: systemd
-- Support: http://lists.freedesktop.org/mailman/listinfo/systemd-devel
-- 
-- Unit httpd.service has begun starting up.
5月 08 16:25:36 lisery01 httpd[1958]: (13)Permission denied: AH00072: make_sock: could not bind to address [::]:8010
5月 08 16:25:36 lisery01 httpd[1958]: (13)Permission denied: AH00072: make_sock: could not bind to address 0.0.0.0:8010
5月 08 16:25:36 lisery01 httpd[1958]: no listening sockets available, shutting down
5月 08 16:25:36 lisery01 httpd[1958]: AH00015: Unable to open logs
5月 08 16:25:36 lisery01 systemd[1]: httpd.service: main process exited, code=exited, status=1/FAILURE
5月 08 16:25:36 lisery01 kill[1960]: kill: cannot find process ""
5月 08 16:25:36 lisery01 systemd[1]: httpd.service: control process exited, code=exited status=1
5月 08 16:25:36 lisery01 systemd[1]: Failed to start The Apache HTTP Server.
-- Subject: Unit httpd.service has failed
-- Defined-By: systemd
-- Support: http://lists.freedesktop.org/mailman/listinfo/systemd-devel
-- 
-- Unit httpd.service has failed.
-- 
-- The result is failed.
5月 08 16:25:36 lisery01 systemd[1]: Unit httpd.service entered failed state.
5月 08 16:25:36 lisery01 systemd[1]: httpd.service failed.
5月 08 16:25:36 lisery01 polkitd[561]: Unregistered Authentication Agent for unix-process:1953:13585 (system bus name :1.14, object path 

重点在于could not bind to address [::]:8010
但是将 vi /etc/httpd/conf/httpd.conf 文件中的listen 改为80(http默认端口)就可以启动成功。更换端口号就会启动失败。

更换http监听端口失败的解决办法

查看selinux下http的端口

[root@cm02 cm]# semanage port -l |grep http
-bash: semanage: 未找到命令

semanage未安装

[root@cm02 cm]# yum -y install policycoreutils-python
完毕!

再次执行查看http端口:

[root@cm02 cm]# semanage port -l|grep http
http_cache_port_t              tcp      8080, 8118, 8123, 10001-10010
http_cache_port_t              udp      3130
http_port_t                    tcp      80, 81, 443, 488, 8008, 8009, 8443, 9000
pegasus_http_port_t            tcp      5988
pegasus_https_port_t           tcp      5989

发现没有目标端口8010,将8010添加进去

[root@cm02 cm]# semanage port -a -t http_port_t -p tcp 8010
[root@cm02 cm]# semanage port -l|grep http
http_cache_port_t              tcp      8080, 8118, 8123, 10001-10010
http_cache_port_t              udp      3130
http_port_t                    tcp      8010, 80, 81, 443, 488, 8008, 8009, 8443, 9000
pegasus_http_port_t            tcp      5988
pegasus_https_port_t           tcp      5989

将 vi /etc/httpd/conf/httpd.conf文件中:

# Change this to Listen on specific IP addresses as shown below to
# prevent Apache from glomming onto all bound IP addresses.
#
#Listen 12.34.56.78:80
Listen 8010
...

#
# ServerName gives the name and port that the server uses to identify itself.
# This can often be determined automatically, but we recommend you specify
# it explicitly to prevent problems during startup.
#
# If your host doesn't have a registered DNS name, enter its IP address here.
#
#ServerName www.example.com:80
ServerName cm02:8010

重启http服务,

[root@cm02 cm]# service httpd start
Redirecting to /bin/systemctl start  httpd.service
[root@cm02 cm]# service httpd status
Redirecting to /bin/systemctl status  httpd.service
● httpd.service - The Apache HTTP Server
   Loaded: loaded (/usr/lib/systemd/system/httpd.service; enabled; vendor preset: disabled)
   Active: active (running) since 三 2018-05-09 11:27:56 CST; 5s ago
     Docs: man:httpd(8)
           man:apachectl(8)
  Process: 12405 ExecStop=/bin/kill -WINCH ${MAINPID} (code=exited, status=0/SUCCESS)
 Main PID: 12426 (httpd)
   Status: "Processing requests..."
   CGroup: /system.slice/httpd.service
           ├─12426 /usr/sbin/httpd -DFOREGROUND
           ├─12427 /usr/sbin/httpd -DFOREGROUND
           ├─12428 /usr/sbin/httpd -DFOREGROUND
           ├─12429 /usr/sbin/httpd -DFOREGROUND
           ├─12430 /usr/sbin/httpd -DFOREGROUND
           └─12431 /usr/sbin/httpd -DFOREGROUND

509 11:27:56 cm02 systemd[1]: Starting The Apache HTTP Server...
509 11:27:56 cm02 systemd[1]: Started The Apache HTTP Server.

问题解决。

猜你喜欢

转载自blog.csdn.net/m0_37618809/article/details/80747812